195857638SErik Schmauss // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2a257e075SBob Moore /******************************************************************************
3a257e075SBob Moore *
4a257e075SBob Moore * Module Name: utdecode - Utility decoding routines (value-to-string)
5a257e075SBob Moore *
6*612c2932SBob Moore * Copyright (C) 2000 - 2023, Intel Corp.
7a257e075SBob Moore *
895857638SErik Schmauss *****************************************************************************/
9a257e075SBob Moore
10a257e075SBob Moore #include <acpi/acpi.h>
11a257e075SBob Moore #include "accommon.h"
12a257e075SBob Moore #include "acnamesp.h"
135a6e7ec3SBob Moore #include "amlcode.h"
14a257e075SBob Moore
15a257e075SBob Moore #define _COMPONENT ACPI_UTILITIES
16a257e075SBob Moore ACPI_MODULE_NAME("utdecode")
17a257e075SBob Moore
18a257e075SBob Moore /*
19a257e075SBob Moore * Properties of the ACPI Object Types, both internal and external.
20a257e075SBob Moore * The table is indexed by values of acpi_object_type
21a257e075SBob Moore */
22a257e075SBob Moore const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES] = {
23a257e075SBob Moore ACPI_NS_NORMAL, /* 00 Any */
24a257e075SBob Moore ACPI_NS_NORMAL, /* 01 Number */
25a257e075SBob Moore ACPI_NS_NORMAL, /* 02 String */
26a257e075SBob Moore ACPI_NS_NORMAL, /* 03 Buffer */
27a257e075SBob Moore ACPI_NS_NORMAL, /* 04 Package */
28a257e075SBob Moore ACPI_NS_NORMAL, /* 05 field_unit */
29a257e075SBob Moore ACPI_NS_NEWSCOPE, /* 06 Device */
30a257e075SBob Moore ACPI_NS_NORMAL, /* 07 Event */
31a257e075SBob Moore ACPI_NS_NEWSCOPE, /* 08 Method */
32a257e075SBob Moore ACPI_NS_NORMAL, /* 09 Mutex */
33a257e075SBob Moore ACPI_NS_NORMAL, /* 10 Region */
34a257e075SBob Moore ACPI_NS_NEWSCOPE, /* 11 Power */
35a257e075SBob Moore ACPI_NS_NEWSCOPE, /* 12 Processor */
36a257e075SBob Moore ACPI_NS_NEWSCOPE, /* 13 Thermal */
37a257e075SBob Moore ACPI_NS_NORMAL, /* 14 buffer_field */
38a257e075SBob Moore ACPI_NS_NORMAL, /* 15 ddb_handle */
39a257e075SBob Moore ACPI_NS_NORMAL, /* 16 Debug Object */
40a257e075SBob Moore ACPI_NS_NORMAL, /* 17 def_field */
41a257e075SBob Moore ACPI_NS_NORMAL, /* 18 bank_field */
42a257e075SBob Moore ACPI_NS_NORMAL, /* 19 index_field */
43a257e075SBob Moore ACPI_NS_NORMAL, /* 20 Reference */
44a257e075SBob Moore ACPI_NS_NORMAL, /* 21 Alias */
45a257e075SBob Moore ACPI_NS_NORMAL, /* 22 method_alias */
46a257e075SBob Moore ACPI_NS_NORMAL, /* 23 Notify */
47a257e075SBob Moore ACPI_NS_NORMAL, /* 24 Address Handler */
48a257e075SBob Moore ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
49a257e075SBob Moore ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
50a257e075SBob Moore ACPI_NS_NEWSCOPE, /* 27 Scope */
51a257e075SBob Moore ACPI_NS_NORMAL, /* 28 Extra */
52a257e075SBob Moore ACPI_NS_NORMAL, /* 29 Data */
53a257e075SBob Moore ACPI_NS_NORMAL /* 30 Invalid */
54a257e075SBob Moore };
55a257e075SBob Moore
56a257e075SBob Moore /*******************************************************************************
57a257e075SBob Moore *
58a257e075SBob Moore * FUNCTION: acpi_ut_get_region_name
59a257e075SBob Moore *
60a257e075SBob Moore * PARAMETERS: Space ID - ID for the region
61a257e075SBob Moore *
62a257e075SBob Moore * RETURN: Decoded region space_id name
63a257e075SBob Moore *
64a257e075SBob Moore * DESCRIPTION: Translate a Space ID into a name string (Debug only)
65a257e075SBob Moore *
66a257e075SBob Moore ******************************************************************************/
67a257e075SBob Moore
68a257e075SBob Moore /* Region type decoding */
69a257e075SBob Moore
70a257e075SBob Moore const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
71540b85abSBob Moore "SystemMemory", /* 0x00 */
72540b85abSBob Moore "SystemIO", /* 0x01 */
73540b85abSBob Moore "PCI_Config", /* 0x02 */
74540b85abSBob Moore "EmbeddedControl", /* 0x03 */
75540b85abSBob Moore "SMBus", /* 0x04 */
76540b85abSBob Moore "SystemCMOS", /* 0x05 */
77540b85abSBob Moore "PCIBARTarget", /* 0x06 */
78540b85abSBob Moore "IPMI", /* 0x07 */
79540b85abSBob Moore "GeneralPurposeIo", /* 0x08 */
80540b85abSBob Moore "GenericSerialBus", /* 0x09 */
81f083906fSErik Kaneda "PCC", /* 0x0A */
82f083906fSErik Kaneda "PlatformRtMechanism" /* 0x0B */
83a257e075SBob Moore };
84a257e075SBob Moore
acpi_ut_get_region_name(u8 space_id)85c118abc5SLABBE Corentin const char *acpi_ut_get_region_name(u8 space_id)
86a257e075SBob Moore {
87a257e075SBob Moore
88a257e075SBob Moore if (space_id >= ACPI_USER_REGION_BEGIN) {
89a257e075SBob Moore return ("UserDefinedRegion");
9082a1b7cbSBob Moore } else if (space_id == ACPI_ADR_SPACE_DATA_TABLE) {
9182a1b7cbSBob Moore return ("DataTable");
9247863b9cSBob Moore } else if (space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
9347863b9cSBob Moore return ("FunctionalFixedHW");
94a257e075SBob Moore } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
95a257e075SBob Moore return ("InvalidSpaceId");
96a257e075SBob Moore }
97a257e075SBob Moore
98c118abc5SLABBE Corentin return (acpi_gbl_region_types[space_id]);
99a257e075SBob Moore }
100a257e075SBob Moore
101a257e075SBob Moore /*******************************************************************************
102a257e075SBob Moore *
103a257e075SBob Moore * FUNCTION: acpi_ut_get_event_name
104a257e075SBob Moore *
105a257e075SBob Moore * PARAMETERS: event_id - Fixed event ID
106a257e075SBob Moore *
107a257e075SBob Moore * RETURN: Decoded event ID name
108a257e075SBob Moore *
109a257e075SBob Moore * DESCRIPTION: Translate a Event ID into a name string (Debug only)
110a257e075SBob Moore *
111a257e075SBob Moore ******************************************************************************/
112a257e075SBob Moore
113a257e075SBob Moore /* Event type decoding */
114a257e075SBob Moore
115a257e075SBob Moore static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
116a257e075SBob Moore "PM_Timer",
117a257e075SBob Moore "GlobalLock",
118a257e075SBob Moore "PowerButton",
119a257e075SBob Moore "SleepButton",
120a257e075SBob Moore "RealTimeClock",
121a257e075SBob Moore };
122a257e075SBob Moore
acpi_ut_get_event_name(u32 event_id)123c118abc5SLABBE Corentin const char *acpi_ut_get_event_name(u32 event_id)
124a257e075SBob Moore {
125a257e075SBob Moore
126a257e075SBob Moore if (event_id > ACPI_EVENT_MAX) {
127a257e075SBob Moore return ("InvalidEventID");
128a257e075SBob Moore }
129a257e075SBob Moore
130c118abc5SLABBE Corentin return (acpi_gbl_event_types[event_id]);
131a257e075SBob Moore }
132a257e075SBob Moore
133a257e075SBob Moore /*******************************************************************************
134a257e075SBob Moore *
135a257e075SBob Moore * FUNCTION: acpi_ut_get_type_name
136a257e075SBob Moore *
137ba494beeSBob Moore * PARAMETERS: type - An ACPI object type
138a257e075SBob Moore *
139a257e075SBob Moore * RETURN: Decoded ACPI object type name
140a257e075SBob Moore *
141a257e075SBob Moore * DESCRIPTION: Translate a Type ID into a name string (Debug only)
142a257e075SBob Moore *
143a257e075SBob Moore ******************************************************************************/
144a257e075SBob Moore
145a257e075SBob Moore /*
146a257e075SBob Moore * Elements of acpi_gbl_ns_type_names below must match
147a257e075SBob Moore * one-to-one with values of acpi_object_type
148a257e075SBob Moore *
149a257e075SBob Moore * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
150a257e075SBob Moore * when stored in a table it really means that we have thus far seen no
1511fad8738SBob Moore * evidence to indicate what type is actually going to be stored for this
1521fad8738SBob Moore & entry.
153a257e075SBob Moore */
154a257e075SBob Moore static const char acpi_gbl_bad_type[] = "UNDEFINED";
155a257e075SBob Moore
156a257e075SBob Moore /* Printable names of the ACPI object types */
157a257e075SBob Moore
158a257e075SBob Moore static const char *acpi_gbl_ns_type_names[] = {
159a257e075SBob Moore /* 00 */ "Untyped",
160a257e075SBob Moore /* 01 */ "Integer",
161a257e075SBob Moore /* 02 */ "String",
162a257e075SBob Moore /* 03 */ "Buffer",
163a257e075SBob Moore /* 04 */ "Package",
164a257e075SBob Moore /* 05 */ "FieldUnit",
165a257e075SBob Moore /* 06 */ "Device",
166a257e075SBob Moore /* 07 */ "Event",
167a257e075SBob Moore /* 08 */ "Method",
168a257e075SBob Moore /* 09 */ "Mutex",
169a257e075SBob Moore /* 10 */ "Region",
170a257e075SBob Moore /* 11 */ "Power",
171a257e075SBob Moore /* 12 */ "Processor",
172a257e075SBob Moore /* 13 */ "Thermal",
173a257e075SBob Moore /* 14 */ "BufferField",
174a257e075SBob Moore /* 15 */ "DdbHandle",
175a257e075SBob Moore /* 16 */ "DebugObject",
176a257e075SBob Moore /* 17 */ "RegionField",
177a257e075SBob Moore /* 18 */ "BankField",
178a257e075SBob Moore /* 19 */ "IndexField",
179a257e075SBob Moore /* 20 */ "Reference",
180a257e075SBob Moore /* 21 */ "Alias",
181a257e075SBob Moore /* 22 */ "MethodAlias",
182a257e075SBob Moore /* 23 */ "Notify",
183a257e075SBob Moore /* 24 */ "AddrHandler",
184a257e075SBob Moore /* 25 */ "ResourceDesc",
185a257e075SBob Moore /* 26 */ "ResourceFld",
186a257e075SBob Moore /* 27 */ "Scope",
187a257e075SBob Moore /* 28 */ "Extra",
188a257e075SBob Moore /* 29 */ "Data",
189a257e075SBob Moore /* 30 */ "Invalid"
190a257e075SBob Moore };
191a257e075SBob Moore
acpi_ut_get_type_name(acpi_object_type type)192c118abc5SLABBE Corentin const char *acpi_ut_get_type_name(acpi_object_type type)
193a257e075SBob Moore {
194a257e075SBob Moore
195a257e075SBob Moore if (type > ACPI_TYPE_INVALID) {
196c118abc5SLABBE Corentin return (acpi_gbl_bad_type);
197a257e075SBob Moore }
198a257e075SBob Moore
199c118abc5SLABBE Corentin return (acpi_gbl_ns_type_names[type]);
200a257e075SBob Moore }
201a257e075SBob Moore
acpi_ut_get_object_type_name(union acpi_operand_object * obj_desc)202c118abc5SLABBE Corentin const char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
203a257e075SBob Moore {
204a5922a1fSBob Moore ACPI_FUNCTION_TRACE(ut_get_object_type_name);
205a257e075SBob Moore
206a257e075SBob Moore if (!obj_desc) {
207a5922a1fSBob Moore ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n"));
2087225d046SBob Moore return_STR("[NULL Object Descriptor]");
209a257e075SBob Moore }
210a257e075SBob Moore
211a5922a1fSBob Moore /* These descriptor types share a common area */
212a5922a1fSBob Moore
213a5922a1fSBob Moore if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) &&
214a5922a1fSBob Moore (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_NAMED)) {
215a5922a1fSBob Moore ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
216a5922a1fSBob Moore "Invalid object descriptor type: 0x%2.2X [%s] (%p)\n",
217a5922a1fSBob Moore ACPI_GET_DESCRIPTOR_TYPE(obj_desc),
218a5922a1fSBob Moore acpi_ut_get_descriptor_name(obj_desc),
219a5922a1fSBob Moore obj_desc));
220a5922a1fSBob Moore
2217225d046SBob Moore return_STR("Invalid object");
222a5922a1fSBob Moore }
223a5922a1fSBob Moore
2244857a94dSJung-uk Kim return_STR(acpi_ut_get_type_name(obj_desc->common.type));
225a257e075SBob Moore }
226a257e075SBob Moore
227a257e075SBob Moore /*******************************************************************************
228a257e075SBob Moore *
229a257e075SBob Moore * FUNCTION: acpi_ut_get_node_name
230a257e075SBob Moore *
231ba494beeSBob Moore * PARAMETERS: object - A namespace node
232a257e075SBob Moore *
233a257e075SBob Moore * RETURN: ASCII name of the node
234a257e075SBob Moore *
235a257e075SBob Moore * DESCRIPTION: Validate the node and return the node's ACPI name.
236a257e075SBob Moore *
237a257e075SBob Moore ******************************************************************************/
238a257e075SBob Moore
acpi_ut_get_node_name(void * object)239c118abc5SLABBE Corentin const char *acpi_ut_get_node_name(void *object)
240a257e075SBob Moore {
241a257e075SBob Moore struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
242a257e075SBob Moore
24332786755SBob Moore /* Must return a string of exactly 4 characters == ACPI_NAMESEG_SIZE */
244a257e075SBob Moore
245a257e075SBob Moore if (!object) {
246a257e075SBob Moore return ("NULL");
247a257e075SBob Moore }
248a257e075SBob Moore
249a257e075SBob Moore /* Check for Root node */
250a257e075SBob Moore
251a257e075SBob Moore if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
252a257e075SBob Moore return ("\"\\\" ");
253a257e075SBob Moore }
254a257e075SBob Moore
255a257e075SBob Moore /* Descriptor must be a namespace node */
256a257e075SBob Moore
257a257e075SBob Moore if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
258a257e075SBob Moore return ("####");
259a257e075SBob Moore }
260a257e075SBob Moore
261a257e075SBob Moore /*
262a257e075SBob Moore * Ensure name is valid. The name was validated/repaired when the node
263a257e075SBob Moore * was created, but make sure it has not been corrupted.
264a257e075SBob Moore */
265a257e075SBob Moore acpi_ut_repair_name(node->name.ascii);
266a257e075SBob Moore
267a257e075SBob Moore /* Return the name */
268a257e075SBob Moore
269a257e075SBob Moore return (node->name.ascii);
270a257e075SBob Moore }
271a257e075SBob Moore
272a257e075SBob Moore /*******************************************************************************
273a257e075SBob Moore *
274a257e075SBob Moore * FUNCTION: acpi_ut_get_descriptor_name
275a257e075SBob Moore *
276ba494beeSBob Moore * PARAMETERS: object - An ACPI object
277a257e075SBob Moore *
278a257e075SBob Moore * RETURN: Decoded name of the descriptor type
279a257e075SBob Moore *
280a257e075SBob Moore * DESCRIPTION: Validate object and return the descriptor type
281a257e075SBob Moore *
282a257e075SBob Moore ******************************************************************************/
283a257e075SBob Moore
284a257e075SBob Moore /* Printable names of object descriptor types */
285a257e075SBob Moore
286a257e075SBob Moore static const char *acpi_gbl_desc_type_names[] = {
287a257e075SBob Moore /* 00 */ "Not a Descriptor",
288894b5cc5SBob Moore /* 01 */ "Cached Object",
289a257e075SBob Moore /* 02 */ "State-Generic",
290a257e075SBob Moore /* 03 */ "State-Update",
291a257e075SBob Moore /* 04 */ "State-Package",
292a257e075SBob Moore /* 05 */ "State-Control",
293a257e075SBob Moore /* 06 */ "State-RootParseScope",
294a257e075SBob Moore /* 07 */ "State-ParseScope",
295a257e075SBob Moore /* 08 */ "State-WalkScope",
296a257e075SBob Moore /* 09 */ "State-Result",
297a257e075SBob Moore /* 10 */ "State-Notify",
298a257e075SBob Moore /* 11 */ "State-Thread",
299894b5cc5SBob Moore /* 12 */ "Tree Walk State",
300894b5cc5SBob Moore /* 13 */ "Parse Tree Op",
301894b5cc5SBob Moore /* 14 */ "Operand Object",
302894b5cc5SBob Moore /* 15 */ "Namespace Node"
303a257e075SBob Moore };
304a257e075SBob Moore
acpi_ut_get_descriptor_name(void * object)305c118abc5SLABBE Corentin const char *acpi_ut_get_descriptor_name(void *object)
306a257e075SBob Moore {
307a257e075SBob Moore
308a257e075SBob Moore if (!object) {
309a257e075SBob Moore return ("NULL OBJECT");
310a257e075SBob Moore }
311a257e075SBob Moore
312a257e075SBob Moore if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
313a257e075SBob Moore return ("Not a Descriptor");
314a257e075SBob Moore }
315a257e075SBob Moore
316c118abc5SLABBE Corentin return (acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE(object)]);
317a257e075SBob Moore }
318a257e075SBob Moore
319a257e075SBob Moore /*******************************************************************************
320a257e075SBob Moore *
321a257e075SBob Moore * FUNCTION: acpi_ut_get_reference_name
322a257e075SBob Moore *
323ba494beeSBob Moore * PARAMETERS: object - An ACPI reference object
324a257e075SBob Moore *
325a257e075SBob Moore * RETURN: Decoded name of the type of reference
326a257e075SBob Moore *
327a257e075SBob Moore * DESCRIPTION: Decode a reference object sub-type to a string.
328a257e075SBob Moore *
329a257e075SBob Moore ******************************************************************************/
330a257e075SBob Moore
331a257e075SBob Moore /* Printable names of reference object sub-types */
332a257e075SBob Moore
333a257e075SBob Moore static const char *acpi_gbl_ref_class_names[] = {
334a257e075SBob Moore /* 00 */ "Local",
335a257e075SBob Moore /* 01 */ "Argument",
336a257e075SBob Moore /* 02 */ "RefOf",
337a257e075SBob Moore /* 03 */ "Index",
338a257e075SBob Moore /* 04 */ "DdbHandle",
339a257e075SBob Moore /* 05 */ "Named Object",
340a257e075SBob Moore /* 06 */ "Debug"
341a257e075SBob Moore };
342a257e075SBob Moore
acpi_ut_get_reference_name(union acpi_operand_object * object)343a257e075SBob Moore const char *acpi_ut_get_reference_name(union acpi_operand_object *object)
344a257e075SBob Moore {
345a257e075SBob Moore
346a257e075SBob Moore if (!object) {
347a257e075SBob Moore return ("NULL Object");
348a257e075SBob Moore }
349a257e075SBob Moore
350a257e075SBob Moore if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
351a257e075SBob Moore return ("Not an Operand object");
352a257e075SBob Moore }
353a257e075SBob Moore
354a257e075SBob Moore if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE) {
355a257e075SBob Moore return ("Not a Reference object");
356a257e075SBob Moore }
357a257e075SBob Moore
358a257e075SBob Moore if (object->reference.class > ACPI_REFCLASS_MAX) {
359a257e075SBob Moore return ("Unknown Reference class");
360a257e075SBob Moore }
361a257e075SBob Moore
362a257e075SBob Moore return (acpi_gbl_ref_class_names[object->reference.class]);
363a257e075SBob Moore }
364a257e075SBob Moore
365a257e075SBob Moore /*******************************************************************************
366a257e075SBob Moore *
367a257e075SBob Moore * FUNCTION: acpi_ut_get_mutex_name
368a257e075SBob Moore *
369a257e075SBob Moore * PARAMETERS: mutex_id - The predefined ID for this mutex.
370a257e075SBob Moore *
371a257e075SBob Moore * RETURN: Decoded name of the internal mutex
372a257e075SBob Moore *
373a257e075SBob Moore * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
374a257e075SBob Moore *
375a257e075SBob Moore ******************************************************************************/
376a257e075SBob Moore
377a257e075SBob Moore /* Names for internal mutex objects, used for debug output */
378a257e075SBob Moore
379c118abc5SLABBE Corentin static const char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
380a257e075SBob Moore "ACPI_MTX_Interpreter",
381a257e075SBob Moore "ACPI_MTX_Namespace",
382a257e075SBob Moore "ACPI_MTX_Tables",
383a257e075SBob Moore "ACPI_MTX_Events",
384a257e075SBob Moore "ACPI_MTX_Caches",
385a257e075SBob Moore "ACPI_MTX_Memory",
386a257e075SBob Moore };
387a257e075SBob Moore
acpi_ut_get_mutex_name(u32 mutex_id)388c118abc5SLABBE Corentin const char *acpi_ut_get_mutex_name(u32 mutex_id)
389a257e075SBob Moore {
390a257e075SBob Moore
391a257e075SBob Moore if (mutex_id > ACPI_MAX_MUTEX) {
392a257e075SBob Moore return ("Invalid Mutex ID");
393a257e075SBob Moore }
394a257e075SBob Moore
395a257e075SBob Moore return (acpi_gbl_mutex_names[mutex_id]);
396a257e075SBob Moore }
397a257e075SBob Moore
3983e1dc644SBob Moore #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
3993e1dc644SBob Moore
4003e1dc644SBob Moore /*
4013e1dc644SBob Moore * Strings and procedures used for debug only
4023e1dc644SBob Moore */
4033e1dc644SBob Moore
404a257e075SBob Moore /*******************************************************************************
405a257e075SBob Moore *
406a257e075SBob Moore * FUNCTION: acpi_ut_get_notify_name
407a257e075SBob Moore *
408a257e075SBob Moore * PARAMETERS: notify_value - Value from the Notify() request
409a257e075SBob Moore *
410a257e075SBob Moore * RETURN: Decoded name for the notify value
411a257e075SBob Moore *
412a257e075SBob Moore * DESCRIPTION: Translate a Notify Value to a notify namestring.
413a257e075SBob Moore *
414a257e075SBob Moore ******************************************************************************/
415a257e075SBob Moore
416a257e075SBob Moore /* Names for Notify() values, used for debug output */
417a257e075SBob Moore
418a88e0ce6SBob Moore static const char *acpi_gbl_generic_notify[ACPI_GENERIC_NOTIFY_MAX + 1] = {
419ea143604SBob Moore /* 00 */ "Bus Check",
420ea143604SBob Moore /* 01 */ "Device Check",
421ea143604SBob Moore /* 02 */ "Device Wake",
422ea143604SBob Moore /* 03 */ "Eject Request",
423ea143604SBob Moore /* 04 */ "Device Check Light",
424ea143604SBob Moore /* 05 */ "Frequency Mismatch",
425ea143604SBob Moore /* 06 */ "Bus Mode Mismatch",
426ea143604SBob Moore /* 07 */ "Power Fault",
427ea143604SBob Moore /* 08 */ "Capabilities Check",
428ea143604SBob Moore /* 09 */ "Device PLD Check",
42906a63e33SBob Moore /* 0A */ "Reserved",
43006a63e33SBob Moore /* 0B */ "System Locality Update",
431a69b4386SBob Moore /* 0C */ "Reserved (was previously Shutdown Request)",
432a88e0ce6SBob Moore /* Reserved in ACPI 6.0 */
433e6f9193cSBob Moore /* 0D */ "System Resource Affinity Update",
434ddcfd66cSErik Schmauss /* 0E */ "Heterogeneous Memory Attributes Update",
435e6f9193cSBob Moore /* ACPI 6.2 */
436ddcfd66cSErik Schmauss /* 0F */ "Error Disconnect Recover"
437ddcfd66cSErik Schmauss /* ACPI 6.3 */
438a257e075SBob Moore };
439a257e075SBob Moore
440a88e0ce6SBob Moore static const char *acpi_gbl_device_notify[5] = {
44106a63e33SBob Moore /* 80 */ "Status Change",
44206a63e33SBob Moore /* 81 */ "Information Change",
44306a63e33SBob Moore /* 82 */ "Device-Specific Change",
444a88e0ce6SBob Moore /* 83 */ "Device-Specific Change",
445a88e0ce6SBob Moore /* 84 */ "Reserved"
44606a63e33SBob Moore };
44706a63e33SBob Moore
448a88e0ce6SBob Moore static const char *acpi_gbl_processor_notify[5] = {
44906a63e33SBob Moore /* 80 */ "Performance Capability Change",
45006a63e33SBob Moore /* 81 */ "C-State Change",
45106a63e33SBob Moore /* 82 */ "Throttling Capability Change",
452a88e0ce6SBob Moore /* 83 */ "Guaranteed Change",
453a88e0ce6SBob Moore /* 84 */ "Minimum Excursion"
45406a63e33SBob Moore };
45506a63e33SBob Moore
456a88e0ce6SBob Moore static const char *acpi_gbl_thermal_notify[5] = {
45706a63e33SBob Moore /* 80 */ "Thermal Status Change",
45806a63e33SBob Moore /* 81 */ "Thermal Trip Point Change",
45906a63e33SBob Moore /* 82 */ "Thermal Device List Change",
460a88e0ce6SBob Moore /* 83 */ "Thermal Relationship Change",
461a88e0ce6SBob Moore /* 84 */ "Reserved"
46206a63e33SBob Moore };
46306a63e33SBob Moore
acpi_ut_get_notify_name(u32 notify_value,acpi_object_type type)46406a63e33SBob Moore const char *acpi_ut_get_notify_name(u32 notify_value, acpi_object_type type)
465a257e075SBob Moore {
466a257e075SBob Moore
467ddcfd66cSErik Schmauss /* 00 - 0F are "common to all object types" (from ACPI Spec) */
46806a63e33SBob Moore
469a88e0ce6SBob Moore if (notify_value <= ACPI_GENERIC_NOTIFY_MAX) {
47006a63e33SBob Moore return (acpi_gbl_generic_notify[notify_value]);
471a257e075SBob Moore }
47206a63e33SBob Moore
473ddcfd66cSErik Schmauss /* 10 - 7F are reserved */
47406a63e33SBob Moore
47506a63e33SBob Moore if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
47606a63e33SBob Moore return ("Reserved");
47706a63e33SBob Moore }
47806a63e33SBob Moore
479a88e0ce6SBob Moore /* 80 - 84 are per-object-type */
48006a63e33SBob Moore
481a88e0ce6SBob Moore if (notify_value <= ACPI_SPECIFIC_NOTIFY_MAX) {
48206a63e33SBob Moore switch (type) {
48306a63e33SBob Moore case ACPI_TYPE_ANY:
48406a63e33SBob Moore case ACPI_TYPE_DEVICE:
48506a63e33SBob Moore return (acpi_gbl_device_notify[notify_value - 0x80]);
48606a63e33SBob Moore
48706a63e33SBob Moore case ACPI_TYPE_PROCESSOR:
48806a63e33SBob Moore return (acpi_gbl_processor_notify[notify_value - 0x80]);
48906a63e33SBob Moore
49006a63e33SBob Moore case ACPI_TYPE_THERMAL:
49106a63e33SBob Moore return (acpi_gbl_thermal_notify[notify_value - 0x80]);
49206a63e33SBob Moore
49306a63e33SBob Moore default:
49406a63e33SBob Moore return ("Target object type does not support notifies");
49506a63e33SBob Moore }
49606a63e33SBob Moore }
49706a63e33SBob Moore
49806a63e33SBob Moore /* 84 - BF are device-specific */
49906a63e33SBob Moore
50006a63e33SBob Moore if (notify_value <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) {
50106a63e33SBob Moore return ("Device-Specific");
50206a63e33SBob Moore }
50306a63e33SBob Moore
50406a63e33SBob Moore /* C0 and above are hardware-specific */
50506a63e33SBob Moore
50606a63e33SBob Moore return ("Hardware-Specific");
507a257e075SBob Moore }
5085a6e7ec3SBob Moore
5095a6e7ec3SBob Moore /*******************************************************************************
5105a6e7ec3SBob Moore *
5115a6e7ec3SBob Moore * FUNCTION: acpi_ut_get_argument_type_name
5125a6e7ec3SBob Moore *
5135a6e7ec3SBob Moore * PARAMETERS: arg_type - an ARGP_* parser argument type
5145a6e7ec3SBob Moore *
5155a6e7ec3SBob Moore * RETURN: Decoded ARGP_* type
5165a6e7ec3SBob Moore *
5175a6e7ec3SBob Moore * DESCRIPTION: Decode an ARGP_* parser type, as defined in the amlcode.h file,
5185a6e7ec3SBob Moore * and used in the acopcode.h file. For example, ARGP_TERMARG.
5195a6e7ec3SBob Moore * Used for debug only.
5205a6e7ec3SBob Moore *
5215a6e7ec3SBob Moore ******************************************************************************/
5225a6e7ec3SBob Moore
5235a6e7ec3SBob Moore static const char *acpi_gbl_argument_type[20] = {
5245a6e7ec3SBob Moore /* 00 */ "Unknown ARGP",
5255a6e7ec3SBob Moore /* 01 */ "ByteData",
5265a6e7ec3SBob Moore /* 02 */ "ByteList",
5275a6e7ec3SBob Moore /* 03 */ "CharList",
5285a6e7ec3SBob Moore /* 04 */ "DataObject",
5295a6e7ec3SBob Moore /* 05 */ "DataObjectList",
5305a6e7ec3SBob Moore /* 06 */ "DWordData",
5315a6e7ec3SBob Moore /* 07 */ "FieldList",
5325a6e7ec3SBob Moore /* 08 */ "Name",
5335a6e7ec3SBob Moore /* 09 */ "NameString",
5345a6e7ec3SBob Moore /* 0A */ "ObjectList",
5355a6e7ec3SBob Moore /* 0B */ "PackageLength",
5365a6e7ec3SBob Moore /* 0C */ "SuperName",
5375a6e7ec3SBob Moore /* 0D */ "Target",
5385a6e7ec3SBob Moore /* 0E */ "TermArg",
5395a6e7ec3SBob Moore /* 0F */ "TermList",
5405a6e7ec3SBob Moore /* 10 */ "WordData",
5415a6e7ec3SBob Moore /* 11 */ "QWordData",
5425a6e7ec3SBob Moore /* 12 */ "SimpleName",
5435a6e7ec3SBob Moore /* 13 */ "NameOrRef"
5445a6e7ec3SBob Moore };
5455a6e7ec3SBob Moore
acpi_ut_get_argument_type_name(u32 arg_type)5465a6e7ec3SBob Moore const char *acpi_ut_get_argument_type_name(u32 arg_type)
5475a6e7ec3SBob Moore {
5485a6e7ec3SBob Moore
5495a6e7ec3SBob Moore if (arg_type > ARGP_MAX) {
5505a6e7ec3SBob Moore return ("Unknown ARGP");
5515a6e7ec3SBob Moore }
5525a6e7ec3SBob Moore
5535a6e7ec3SBob Moore return (acpi_gbl_argument_type[arg_type]);
5545a6e7ec3SBob Moore }
5555a6e7ec3SBob Moore
556a257e075SBob Moore #endif
557a257e075SBob Moore
558a257e075SBob Moore /*******************************************************************************
559a257e075SBob Moore *
560a257e075SBob Moore * FUNCTION: acpi_ut_valid_object_type
561a257e075SBob Moore *
562ba494beeSBob Moore * PARAMETERS: type - Object type to be validated
563a257e075SBob Moore *
564a257e075SBob Moore * RETURN: TRUE if valid object type, FALSE otherwise
565a257e075SBob Moore *
566a257e075SBob Moore * DESCRIPTION: Validate an object type
567a257e075SBob Moore *
568a257e075SBob Moore ******************************************************************************/
569a257e075SBob Moore
acpi_ut_valid_object_type(acpi_object_type type)570a257e075SBob Moore u8 acpi_ut_valid_object_type(acpi_object_type type)
571a257e075SBob Moore {
572a257e075SBob Moore
573a257e075SBob Moore if (type > ACPI_TYPE_LOCAL_MAX) {
574a257e075SBob Moore
575a257e075SBob Moore /* Note: Assumes all TYPEs are contiguous (external/local) */
576a257e075SBob Moore
577a257e075SBob Moore return (FALSE);
578a257e075SBob Moore }
579a257e075SBob Moore
580a257e075SBob Moore return (TRUE);
581a257e075SBob Moore }
582