Deleted Added
full compact
utdecode.c (218585) utdecode.c (218590)
1/******************************************************************************
2 *
3 * Module Name: utdecode - Utility decoding routines (value-to-string)
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2011, 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#define __UTDECODE_C__
45
1/******************************************************************************
2 *
3 * Module Name: utdecode - Utility decoding routines (value-to-string)
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2011, 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#define __UTDECODE_C__
45
46#include "acpi.h"
47#include "accommon.h"
48#include "acnamesp.h"
46#include <contrib/dev/acpica/include/acpi.h>
47#include <contrib/dev/acpica/include/accommon.h>
48#include <contrib/dev/acpica/include/acnamesp.h>
49
50#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utdecode")
52
53
54/*******************************************************************************
55 *
56 * FUNCTION: AcpiFormatException
57 *
58 * PARAMETERS: Status - The ACPI_STATUS code to be formatted
59 *
60 * RETURN: A string containing the exception text. A valid pointer is
61 * always returned.
62 *
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.
65 *
66 ******************************************************************************/
67
68const char *
69AcpiFormatException (
70 ACPI_STATUS Status)
71{
72 const char *Exception = NULL;
73
74
75 ACPI_FUNCTION_ENTRY ();
76
77
78 Exception = AcpiUtValidateException (Status);
79 if (!Exception)
80 {
81 /* Exception code was not recognized */
82
83 ACPI_ERROR ((AE_INFO,
84 "Unknown exception code: 0x%8.8X", Status));
85
86 Exception = "UNKNOWN_STATUS_CODE";
87 }
88
89 return (ACPI_CAST_PTR (const char, Exception));
90}
91
92ACPI_EXPORT_SYMBOL (AcpiFormatException)
93
94
95/*
96 * Properties of the ACPI Object Types, both internal and external.
97 * The table is indexed by values of ACPI_OBJECT_TYPE
98 */
99const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] =
100{
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 */
132};
133
134
135/*******************************************************************************
136 *
137 * FUNCTION: AcpiUtHexToAsciiChar
138 *
139 * PARAMETERS: Integer - Contains the hex digit
140 * Position - bit position of the digit within the
141 * integer (multiple of 4)
142 *
143 * RETURN: The converted Ascii character
144 *
145 * DESCRIPTION: Convert a hex digit to an Ascii character
146 *
147 ******************************************************************************/
148
149/* Hex to ASCII conversion table */
150
151static const char AcpiGbl_HexToAscii[] =
152{
153 '0','1','2','3','4','5','6','7',
154 '8','9','A','B','C','D','E','F'
155};
156
157char
158AcpiUtHexToAsciiChar (
159 UINT64 Integer,
160 UINT32 Position)
161{
162
163 return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
164}
165
166
167/*******************************************************************************
168 *
169 * FUNCTION: AcpiUtGetRegionName
170 *
171 * PARAMETERS: Space ID - ID for the region
172 *
173 * RETURN: Decoded region SpaceId name
174 *
175 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
176 *
177 ******************************************************************************/
178
179/* Region type decoding */
180
181const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
182{
183 "SystemMemory",
184 "SystemIO",
185 "PCI_Config",
186 "EmbeddedControl",
187 "SMBus",
188 "SystemCMOS",
189 "PCIBARTarget",
190 "IPMI",
191 "DataTable"
192};
193
194
195char *
196AcpiUtGetRegionName (
197 UINT8 SpaceId)
198{
199
200 if (SpaceId >= ACPI_USER_REGION_BEGIN)
201 {
202 return ("UserDefinedRegion");
203 }
204 else if (SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE)
205 {
206 return ("FunctionalFixedHW");
207 }
208 else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
209 {
210 return ("InvalidSpaceId");
211 }
212
213 return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
214}
215
216
217/*******************************************************************************
218 *
219 * FUNCTION: AcpiUtGetEventName
220 *
221 * PARAMETERS: EventId - Fixed event ID
222 *
223 * RETURN: Decoded event ID name
224 *
225 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
226 *
227 ******************************************************************************/
228
229/* Event type decoding */
230
231static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
232{
233 "PM_Timer",
234 "GlobalLock",
235 "PowerButton",
236 "SleepButton",
237 "RealTimeClock",
238};
239
240
241char *
242AcpiUtGetEventName (
243 UINT32 EventId)
244{
245
246 if (EventId > ACPI_EVENT_MAX)
247 {
248 return ("InvalidEventID");
249 }
250
251 return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
252}
253
254
255/*******************************************************************************
256 *
257 * FUNCTION: AcpiUtGetTypeName
258 *
259 * PARAMETERS: Type - An ACPI object type
260 *
261 * RETURN: Decoded ACPI object type name
262 *
263 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
264 *
265 ******************************************************************************/
266
267/*
268 * Elements of AcpiGbl_NsTypeNames below must match
269 * one-to-one with values of ACPI_OBJECT_TYPE
270 *
271 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
272 * when stored in a table it really means that we have thus far seen no
273 * evidence to indicate what type is actually going to be stored for this entry.
274 */
275static const char AcpiGbl_BadType[] = "UNDEFINED";
276
277/* Printable names of the ACPI object types */
278
279static const char *AcpiGbl_NsTypeNames[] =
280{
281 /* 00 */ "Untyped",
282 /* 01 */ "Integer",
283 /* 02 */ "String",
284 /* 03 */ "Buffer",
285 /* 04 */ "Package",
286 /* 05 */ "FieldUnit",
287 /* 06 */ "Device",
288 /* 07 */ "Event",
289 /* 08 */ "Method",
290 /* 09 */ "Mutex",
291 /* 10 */ "Region",
292 /* 11 */ "Power",
293 /* 12 */ "Processor",
294 /* 13 */ "Thermal",
295 /* 14 */ "BufferField",
296 /* 15 */ "DdbHandle",
297 /* 16 */ "DebugObject",
298 /* 17 */ "RegionField",
299 /* 18 */ "BankField",
300 /* 19 */ "IndexField",
301 /* 20 */ "Reference",
302 /* 21 */ "Alias",
303 /* 22 */ "MethodAlias",
304 /* 23 */ "Notify",
305 /* 24 */ "AddrHandler",
306 /* 25 */ "ResourceDesc",
307 /* 26 */ "ResourceFld",
308 /* 27 */ "Scope",
309 /* 28 */ "Extra",
310 /* 29 */ "Data",
311 /* 30 */ "Invalid"
312};
313
314
315char *
316AcpiUtGetTypeName (
317 ACPI_OBJECT_TYPE Type)
318{
319
320 if (Type > ACPI_TYPE_INVALID)
321 {
322 return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
323 }
324
325 return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
326}
327
328
329char *
330AcpiUtGetObjectTypeName (
331 ACPI_OPERAND_OBJECT *ObjDesc)
332{
333
334 if (!ObjDesc)
335 {
336 return ("[NULL Object Descriptor]");
337 }
338
339 return (AcpiUtGetTypeName (ObjDesc->Common.Type));
340}
341
342
343/*******************************************************************************
344 *
345 * FUNCTION: AcpiUtGetNodeName
346 *
347 * PARAMETERS: Object - A namespace node
348 *
349 * RETURN: ASCII name of the node
350 *
351 * DESCRIPTION: Validate the node and return the node's ACPI name.
352 *
353 ******************************************************************************/
354
355char *
356AcpiUtGetNodeName (
357 void *Object)
358{
359 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object;
360
361
362 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
363
364 if (!Object)
365 {
366 return ("NULL");
367 }
368
369 /* Check for Root node */
370
371 if ((Object == ACPI_ROOT_OBJECT) ||
372 (Object == AcpiGbl_RootNode))
373 {
374 return ("\"\\\" ");
375 }
376
377 /* Descriptor must be a namespace node */
378
379 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
380 {
381 return ("####");
382 }
383
384 /*
385 * Ensure name is valid. The name was validated/repaired when the node
386 * was created, but make sure it has not been corrupted.
387 */
388 AcpiUtRepairName (Node->Name.Ascii);
389
390 /* Return the name */
391
392 return (Node->Name.Ascii);
393}
394
395
396/*******************************************************************************
397 *
398 * FUNCTION: AcpiUtGetDescriptorName
399 *
400 * PARAMETERS: Object - An ACPI object
401 *
402 * RETURN: Decoded name of the descriptor type
403 *
404 * DESCRIPTION: Validate object and return the descriptor type
405 *
406 ******************************************************************************/
407
408/* Printable names of object descriptor types */
409
410static const char *AcpiGbl_DescTypeNames[] =
411{
412 /* 00 */ "Not a Descriptor",
413 /* 01 */ "Cached",
414 /* 02 */ "State-Generic",
415 /* 03 */ "State-Update",
416 /* 04 */ "State-Package",
417 /* 05 */ "State-Control",
418 /* 06 */ "State-RootParseScope",
419 /* 07 */ "State-ParseScope",
420 /* 08 */ "State-WalkScope",
421 /* 09 */ "State-Result",
422 /* 10 */ "State-Notify",
423 /* 11 */ "State-Thread",
424 /* 12 */ "Walk",
425 /* 13 */ "Parser",
426 /* 14 */ "Operand",
427 /* 15 */ "Node"
428};
429
430
431char *
432AcpiUtGetDescriptorName (
433 void *Object)
434{
435
436 if (!Object)
437 {
438 return ("NULL OBJECT");
439 }
440
441 if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
442 {
443 return ("Not a Descriptor");
444 }
445
446 return (ACPI_CAST_PTR (char,
447 AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
448
449}
450
451
452/*******************************************************************************
453 *
454 * FUNCTION: AcpiUtGetReferenceName
455 *
456 * PARAMETERS: Object - An ACPI reference object
457 *
458 * RETURN: Decoded name of the type of reference
459 *
460 * DESCRIPTION: Decode a reference object sub-type to a string.
461 *
462 ******************************************************************************/
463
464/* Printable names of reference object sub-types */
465
466static const char *AcpiGbl_RefClassNames[] =
467{
468 /* 00 */ "Local",
469 /* 01 */ "Argument",
470 /* 02 */ "RefOf",
471 /* 03 */ "Index",
472 /* 04 */ "DdbHandle",
473 /* 05 */ "Named Object",
474 /* 06 */ "Debug"
475};
476
477const char *
478AcpiUtGetReferenceName (
479 ACPI_OPERAND_OBJECT *Object)
480{
481
482 if (!Object)
483 {
484 return ("NULL Object");
485 }
486
487 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
488 {
489 return ("Not an Operand object");
490 }
491
492 if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
493 {
494 return ("Not a Reference object");
495 }
496
497 if (Object->Reference.Class > ACPI_REFCLASS_MAX)
498 {
499 return ("Unknown Reference class");
500 }
501
502 return (AcpiGbl_RefClassNames[Object->Reference.Class]);
503}
504
505
506#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
507/*
508 * Strings and procedures used for debug only
509 */
510
511/*******************************************************************************
512 *
513 * FUNCTION: AcpiUtGetMutexName
514 *
515 * PARAMETERS: MutexId - The predefined ID for this mutex.
516 *
517 * RETURN: Decoded name of the internal mutex
518 *
519 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
520 *
521 ******************************************************************************/
522
523/* Names for internal mutex objects, used for debug output */
524
525static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
526{
527 "ACPI_MTX_Interpreter",
528 "ACPI_MTX_Namespace",
529 "ACPI_MTX_Tables",
530 "ACPI_MTX_Events",
531 "ACPI_MTX_Caches",
532 "ACPI_MTX_Memory",
533 "ACPI_MTX_CommandComplete",
534 "ACPI_MTX_CommandReady"
535};
536
537char *
538AcpiUtGetMutexName (
539 UINT32 MutexId)
540{
541
542 if (MutexId > ACPI_MAX_MUTEX)
543 {
544 return ("Invalid Mutex ID");
545 }
546
547 return (AcpiGbl_MutexNames[MutexId]);
548}
549
550
551/*******************************************************************************
552 *
553 * FUNCTION: AcpiUtGetNotifyName
554 *
555 * PARAMETERS: NotifyValue - Value from the Notify() request
556 *
557 * RETURN: Decoded name for the notify value
558 *
559 * DESCRIPTION: Translate a Notify Value to a notify namestring.
560 *
561 ******************************************************************************/
562
563/* Names for Notify() values, used for debug output */
564
565static const char *AcpiGbl_NotifyValueNames[] =
566{
567 "Bus Check",
568 "Device Check",
569 "Device Wake",
570 "Eject Request",
571 "Device Check Light",
572 "Frequency Mismatch",
573 "Bus Mode Mismatch",
574 "Power Fault",
575 "Capabilities Check",
576 "Device PLD Check",
577 "Reserved",
578 "System Locality Update"
579};
580
581const char *
582AcpiUtGetNotifyName (
583 UINT32 NotifyValue)
584{
585
586 if (NotifyValue <= ACPI_NOTIFY_MAX)
587 {
588 return (AcpiGbl_NotifyValueNames[NotifyValue]);
589 }
590 else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
591 {
592 return ("Reserved");
593 }
594 else /* Greater or equal to 0x80 */
595 {
596 return ("**Device Specific**");
597 }
598}
599#endif
600
601
602/*******************************************************************************
603 *
604 * FUNCTION: AcpiUtValidObjectType
605 *
606 * PARAMETERS: Type - Object type to be validated
607 *
608 * RETURN: TRUE if valid object type, FALSE otherwise
609 *
610 * DESCRIPTION: Validate an object type
611 *
612 ******************************************************************************/
613
614BOOLEAN
615AcpiUtValidObjectType (
616 ACPI_OBJECT_TYPE Type)
617{
618
619 if (Type > ACPI_TYPE_LOCAL_MAX)
620 {
621 /* Note: Assumes all TYPEs are contiguous (external/local) */
622
623 return (FALSE);
624 }
625
626 return (TRUE);
627}
49
50#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utdecode")
52
53
54/*******************************************************************************
55 *
56 * FUNCTION: AcpiFormatException
57 *
58 * PARAMETERS: Status - The ACPI_STATUS code to be formatted
59 *
60 * RETURN: A string containing the exception text. A valid pointer is
61 * always returned.
62 *
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.
65 *
66 ******************************************************************************/
67
68const char *
69AcpiFormatException (
70 ACPI_STATUS Status)
71{
72 const char *Exception = NULL;
73
74
75 ACPI_FUNCTION_ENTRY ();
76
77
78 Exception = AcpiUtValidateException (Status);
79 if (!Exception)
80 {
81 /* Exception code was not recognized */
82
83 ACPI_ERROR ((AE_INFO,
84 "Unknown exception code: 0x%8.8X", Status));
85
86 Exception = "UNKNOWN_STATUS_CODE";
87 }
88
89 return (ACPI_CAST_PTR (const char, Exception));
90}
91
92ACPI_EXPORT_SYMBOL (AcpiFormatException)
93
94
95/*
96 * Properties of the ACPI Object Types, both internal and external.
97 * The table is indexed by values of ACPI_OBJECT_TYPE
98 */
99const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] =
100{
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 */
132};
133
134
135/*******************************************************************************
136 *
137 * FUNCTION: AcpiUtHexToAsciiChar
138 *
139 * PARAMETERS: Integer - Contains the hex digit
140 * Position - bit position of the digit within the
141 * integer (multiple of 4)
142 *
143 * RETURN: The converted Ascii character
144 *
145 * DESCRIPTION: Convert a hex digit to an Ascii character
146 *
147 ******************************************************************************/
148
149/* Hex to ASCII conversion table */
150
151static const char AcpiGbl_HexToAscii[] =
152{
153 '0','1','2','3','4','5','6','7',
154 '8','9','A','B','C','D','E','F'
155};
156
157char
158AcpiUtHexToAsciiChar (
159 UINT64 Integer,
160 UINT32 Position)
161{
162
163 return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
164}
165
166
167/*******************************************************************************
168 *
169 * FUNCTION: AcpiUtGetRegionName
170 *
171 * PARAMETERS: Space ID - ID for the region
172 *
173 * RETURN: Decoded region SpaceId name
174 *
175 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
176 *
177 ******************************************************************************/
178
179/* Region type decoding */
180
181const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
182{
183 "SystemMemory",
184 "SystemIO",
185 "PCI_Config",
186 "EmbeddedControl",
187 "SMBus",
188 "SystemCMOS",
189 "PCIBARTarget",
190 "IPMI",
191 "DataTable"
192};
193
194
195char *
196AcpiUtGetRegionName (
197 UINT8 SpaceId)
198{
199
200 if (SpaceId >= ACPI_USER_REGION_BEGIN)
201 {
202 return ("UserDefinedRegion");
203 }
204 else if (SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE)
205 {
206 return ("FunctionalFixedHW");
207 }
208 else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
209 {
210 return ("InvalidSpaceId");
211 }
212
213 return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
214}
215
216
217/*******************************************************************************
218 *
219 * FUNCTION: AcpiUtGetEventName
220 *
221 * PARAMETERS: EventId - Fixed event ID
222 *
223 * RETURN: Decoded event ID name
224 *
225 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
226 *
227 ******************************************************************************/
228
229/* Event type decoding */
230
231static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
232{
233 "PM_Timer",
234 "GlobalLock",
235 "PowerButton",
236 "SleepButton",
237 "RealTimeClock",
238};
239
240
241char *
242AcpiUtGetEventName (
243 UINT32 EventId)
244{
245
246 if (EventId > ACPI_EVENT_MAX)
247 {
248 return ("InvalidEventID");
249 }
250
251 return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
252}
253
254
255/*******************************************************************************
256 *
257 * FUNCTION: AcpiUtGetTypeName
258 *
259 * PARAMETERS: Type - An ACPI object type
260 *
261 * RETURN: Decoded ACPI object type name
262 *
263 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
264 *
265 ******************************************************************************/
266
267/*
268 * Elements of AcpiGbl_NsTypeNames below must match
269 * one-to-one with values of ACPI_OBJECT_TYPE
270 *
271 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
272 * when stored in a table it really means that we have thus far seen no
273 * evidence to indicate what type is actually going to be stored for this entry.
274 */
275static const char AcpiGbl_BadType[] = "UNDEFINED";
276
277/* Printable names of the ACPI object types */
278
279static const char *AcpiGbl_NsTypeNames[] =
280{
281 /* 00 */ "Untyped",
282 /* 01 */ "Integer",
283 /* 02 */ "String",
284 /* 03 */ "Buffer",
285 /* 04 */ "Package",
286 /* 05 */ "FieldUnit",
287 /* 06 */ "Device",
288 /* 07 */ "Event",
289 /* 08 */ "Method",
290 /* 09 */ "Mutex",
291 /* 10 */ "Region",
292 /* 11 */ "Power",
293 /* 12 */ "Processor",
294 /* 13 */ "Thermal",
295 /* 14 */ "BufferField",
296 /* 15 */ "DdbHandle",
297 /* 16 */ "DebugObject",
298 /* 17 */ "RegionField",
299 /* 18 */ "BankField",
300 /* 19 */ "IndexField",
301 /* 20 */ "Reference",
302 /* 21 */ "Alias",
303 /* 22 */ "MethodAlias",
304 /* 23 */ "Notify",
305 /* 24 */ "AddrHandler",
306 /* 25 */ "ResourceDesc",
307 /* 26 */ "ResourceFld",
308 /* 27 */ "Scope",
309 /* 28 */ "Extra",
310 /* 29 */ "Data",
311 /* 30 */ "Invalid"
312};
313
314
315char *
316AcpiUtGetTypeName (
317 ACPI_OBJECT_TYPE Type)
318{
319
320 if (Type > ACPI_TYPE_INVALID)
321 {
322 return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
323 }
324
325 return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
326}
327
328
329char *
330AcpiUtGetObjectTypeName (
331 ACPI_OPERAND_OBJECT *ObjDesc)
332{
333
334 if (!ObjDesc)
335 {
336 return ("[NULL Object Descriptor]");
337 }
338
339 return (AcpiUtGetTypeName (ObjDesc->Common.Type));
340}
341
342
343/*******************************************************************************
344 *
345 * FUNCTION: AcpiUtGetNodeName
346 *
347 * PARAMETERS: Object - A namespace node
348 *
349 * RETURN: ASCII name of the node
350 *
351 * DESCRIPTION: Validate the node and return the node's ACPI name.
352 *
353 ******************************************************************************/
354
355char *
356AcpiUtGetNodeName (
357 void *Object)
358{
359 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object;
360
361
362 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
363
364 if (!Object)
365 {
366 return ("NULL");
367 }
368
369 /* Check for Root node */
370
371 if ((Object == ACPI_ROOT_OBJECT) ||
372 (Object == AcpiGbl_RootNode))
373 {
374 return ("\"\\\" ");
375 }
376
377 /* Descriptor must be a namespace node */
378
379 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
380 {
381 return ("####");
382 }
383
384 /*
385 * Ensure name is valid. The name was validated/repaired when the node
386 * was created, but make sure it has not been corrupted.
387 */
388 AcpiUtRepairName (Node->Name.Ascii);
389
390 /* Return the name */
391
392 return (Node->Name.Ascii);
393}
394
395
396/*******************************************************************************
397 *
398 * FUNCTION: AcpiUtGetDescriptorName
399 *
400 * PARAMETERS: Object - An ACPI object
401 *
402 * RETURN: Decoded name of the descriptor type
403 *
404 * DESCRIPTION: Validate object and return the descriptor type
405 *
406 ******************************************************************************/
407
408/* Printable names of object descriptor types */
409
410static const char *AcpiGbl_DescTypeNames[] =
411{
412 /* 00 */ "Not a Descriptor",
413 /* 01 */ "Cached",
414 /* 02 */ "State-Generic",
415 /* 03 */ "State-Update",
416 /* 04 */ "State-Package",
417 /* 05 */ "State-Control",
418 /* 06 */ "State-RootParseScope",
419 /* 07 */ "State-ParseScope",
420 /* 08 */ "State-WalkScope",
421 /* 09 */ "State-Result",
422 /* 10 */ "State-Notify",
423 /* 11 */ "State-Thread",
424 /* 12 */ "Walk",
425 /* 13 */ "Parser",
426 /* 14 */ "Operand",
427 /* 15 */ "Node"
428};
429
430
431char *
432AcpiUtGetDescriptorName (
433 void *Object)
434{
435
436 if (!Object)
437 {
438 return ("NULL OBJECT");
439 }
440
441 if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
442 {
443 return ("Not a Descriptor");
444 }
445
446 return (ACPI_CAST_PTR (char,
447 AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
448
449}
450
451
452/*******************************************************************************
453 *
454 * FUNCTION: AcpiUtGetReferenceName
455 *
456 * PARAMETERS: Object - An ACPI reference object
457 *
458 * RETURN: Decoded name of the type of reference
459 *
460 * DESCRIPTION: Decode a reference object sub-type to a string.
461 *
462 ******************************************************************************/
463
464/* Printable names of reference object sub-types */
465
466static const char *AcpiGbl_RefClassNames[] =
467{
468 /* 00 */ "Local",
469 /* 01 */ "Argument",
470 /* 02 */ "RefOf",
471 /* 03 */ "Index",
472 /* 04 */ "DdbHandle",
473 /* 05 */ "Named Object",
474 /* 06 */ "Debug"
475};
476
477const char *
478AcpiUtGetReferenceName (
479 ACPI_OPERAND_OBJECT *Object)
480{
481
482 if (!Object)
483 {
484 return ("NULL Object");
485 }
486
487 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
488 {
489 return ("Not an Operand object");
490 }
491
492 if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
493 {
494 return ("Not a Reference object");
495 }
496
497 if (Object->Reference.Class > ACPI_REFCLASS_MAX)
498 {
499 return ("Unknown Reference class");
500 }
501
502 return (AcpiGbl_RefClassNames[Object->Reference.Class]);
503}
504
505
506#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
507/*
508 * Strings and procedures used for debug only
509 */
510
511/*******************************************************************************
512 *
513 * FUNCTION: AcpiUtGetMutexName
514 *
515 * PARAMETERS: MutexId - The predefined ID for this mutex.
516 *
517 * RETURN: Decoded name of the internal mutex
518 *
519 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
520 *
521 ******************************************************************************/
522
523/* Names for internal mutex objects, used for debug output */
524
525static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
526{
527 "ACPI_MTX_Interpreter",
528 "ACPI_MTX_Namespace",
529 "ACPI_MTX_Tables",
530 "ACPI_MTX_Events",
531 "ACPI_MTX_Caches",
532 "ACPI_MTX_Memory",
533 "ACPI_MTX_CommandComplete",
534 "ACPI_MTX_CommandReady"
535};
536
537char *
538AcpiUtGetMutexName (
539 UINT32 MutexId)
540{
541
542 if (MutexId > ACPI_MAX_MUTEX)
543 {
544 return ("Invalid Mutex ID");
545 }
546
547 return (AcpiGbl_MutexNames[MutexId]);
548}
549
550
551/*******************************************************************************
552 *
553 * FUNCTION: AcpiUtGetNotifyName
554 *
555 * PARAMETERS: NotifyValue - Value from the Notify() request
556 *
557 * RETURN: Decoded name for the notify value
558 *
559 * DESCRIPTION: Translate a Notify Value to a notify namestring.
560 *
561 ******************************************************************************/
562
563/* Names for Notify() values, used for debug output */
564
565static const char *AcpiGbl_NotifyValueNames[] =
566{
567 "Bus Check",
568 "Device Check",
569 "Device Wake",
570 "Eject Request",
571 "Device Check Light",
572 "Frequency Mismatch",
573 "Bus Mode Mismatch",
574 "Power Fault",
575 "Capabilities Check",
576 "Device PLD Check",
577 "Reserved",
578 "System Locality Update"
579};
580
581const char *
582AcpiUtGetNotifyName (
583 UINT32 NotifyValue)
584{
585
586 if (NotifyValue <= ACPI_NOTIFY_MAX)
587 {
588 return (AcpiGbl_NotifyValueNames[NotifyValue]);
589 }
590 else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
591 {
592 return ("Reserved");
593 }
594 else /* Greater or equal to 0x80 */
595 {
596 return ("**Device Specific**");
597 }
598}
599#endif
600
601
602/*******************************************************************************
603 *
604 * FUNCTION: AcpiUtValidObjectType
605 *
606 * PARAMETERS: Type - Object type to be validated
607 *
608 * RETURN: TRUE if valid object type, FALSE otherwise
609 *
610 * DESCRIPTION: Validate an object type
611 *
612 ******************************************************************************/
613
614BOOLEAN
615AcpiUtValidObjectType (
616 ACPI_OBJECT_TYPE Type)
617{
618
619 if (Type > ACPI_TYPE_LOCAL_MAX)
620 {
621 /* Note: Assumes all TYPEs are contiguous (external/local) */
622
623 return (FALSE);
624 }
625
626 return (TRUE);
627}