1
2
3
4
5
6
7
8
9
10#include <acpi/acpi.h>
11#include "accommon.h"
12#include "acnamesp.h"
13#include "amlcode.h"
14
15#define _COMPONENT ACPI_UTILITIES
16ACPI_MODULE_NAME("utdecode")
17
18
19
20
21
22const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES] = {
23 ACPI_NS_NORMAL,
24 ACPI_NS_NORMAL,
25 ACPI_NS_NORMAL,
26 ACPI_NS_NORMAL,
27 ACPI_NS_NORMAL,
28 ACPI_NS_NORMAL,
29 ACPI_NS_NEWSCOPE,
30 ACPI_NS_NORMAL,
31 ACPI_NS_NEWSCOPE,
32 ACPI_NS_NORMAL,
33 ACPI_NS_NORMAL,
34 ACPI_NS_NEWSCOPE,
35 ACPI_NS_NEWSCOPE,
36 ACPI_NS_NEWSCOPE,
37 ACPI_NS_NORMAL,
38 ACPI_NS_NORMAL,
39 ACPI_NS_NORMAL,
40 ACPI_NS_NORMAL,
41 ACPI_NS_NORMAL,
42 ACPI_NS_NORMAL,
43 ACPI_NS_NORMAL,
44 ACPI_NS_NORMAL,
45 ACPI_NS_NORMAL,
46 ACPI_NS_NORMAL,
47 ACPI_NS_NORMAL,
48 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,
49 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,
50 ACPI_NS_NEWSCOPE,
51 ACPI_NS_NORMAL,
52 ACPI_NS_NORMAL,
53 ACPI_NS_NORMAL
54};
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
71 "SystemMemory",
72 "SystemIO",
73 "PCI_Config",
74 "EmbeddedControl",
75 "SMBus",
76 "SystemCMOS",
77 "PCIBARTarget",
78 "IPMI",
79 "GeneralPurposeIo",
80 "GenericSerialBus",
81 "PCC",
82 "PlatformRtMechanism"
83};
84
85const char *acpi_ut_get_region_name(u8 space_id)
86{
87
88 if (space_id >= ACPI_USER_REGION_BEGIN) {
89 return ("UserDefinedRegion");
90 } else if (space_id == ACPI_ADR_SPACE_DATA_TABLE) {
91 return ("DataTable");
92 } else if (space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
93 return ("FunctionalFixedHW");
94 } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
95 return ("InvalidSpaceId");
96 }
97
98 return (acpi_gbl_region_types[space_id]);
99}
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
116 "PM_Timer",
117 "GlobalLock",
118 "PowerButton",
119 "SleepButton",
120 "RealTimeClock",
121};
122
123const char *acpi_ut_get_event_name(u32 event_id)
124{
125
126 if (event_id > ACPI_EVENT_MAX) {
127 return ("InvalidEventID");
128 }
129
130 return (acpi_gbl_event_types[event_id]);
131}
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154static const char acpi_gbl_bad_type[] = "UNDEFINED";
155
156
157
158static const char *acpi_gbl_ns_type_names[] = {
159 "Untyped",
160 "Integer",
161 "String",
162 "Buffer",
163 "Package",
164 "FieldUnit",
165 "Device",
166 "Event",
167 "Method",
168 "Mutex",
169 "Region",
170 "Power",
171 "Processor",
172 "Thermal",
173 "BufferField",
174 "DdbHandle",
175 "DebugObject",
176 "RegionField",
177 "BankField",
178 "IndexField",
179 "Reference",
180 "Alias",
181 "MethodAlias",
182 "Notify",
183 "AddrHandler",
184 "ResourceDesc",
185 "ResourceFld",
186 "Scope",
187 "Extra",
188 "Data",
189 "Invalid"
190};
191
192const char *acpi_ut_get_type_name(acpi_object_type type)
193{
194
195 if (type > ACPI_TYPE_INVALID) {
196 return (acpi_gbl_bad_type);
197 }
198
199 return (acpi_gbl_ns_type_names[type]);
200}
201
202const char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
203{
204 ACPI_FUNCTION_TRACE(ut_get_object_type_name);
205
206 if (!obj_desc) {
207 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n"));
208 return_STR("[NULL Object Descriptor]");
209 }
210
211
212
213 if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) &&
214 (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_NAMED)) {
215 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
216 "Invalid object descriptor type: 0x%2.2X [%s] (%p)\n",
217 ACPI_GET_DESCRIPTOR_TYPE(obj_desc),
218 acpi_ut_get_descriptor_name(obj_desc),
219 obj_desc));
220
221 return_STR("Invalid object");
222 }
223
224 return_STR(acpi_ut_get_type_name(obj_desc->common.type));
225}
226
227
228
229
230
231
232
233
234
235
236
237
238
239const char *acpi_ut_get_node_name(void *object)
240{
241 struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
242
243
244
245 if (!object) {
246 return ("NULL");
247 }
248
249
250
251 if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
252 return ("\"\\\" ");
253 }
254
255
256
257 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
258 return ("####");
259 }
260
261
262
263
264
265 acpi_ut_repair_name(node->name.ascii);
266
267
268
269 return (node->name.ascii);
270}
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286static const char *acpi_gbl_desc_type_names[] = {
287 "Not a Descriptor",
288 "Cached Object",
289 "State-Generic",
290 "State-Update",
291 "State-Package",
292 "State-Control",
293 "State-RootParseScope",
294 "State-ParseScope",
295 "State-WalkScope",
296 "State-Result",
297 "State-Notify",
298 "State-Thread",
299 "Tree Walk State",
300 "Parse Tree Op",
301 "Operand Object",
302 "Namespace Node"
303};
304
305const char *acpi_ut_get_descriptor_name(void *object)
306{
307
308 if (!object) {
309 return ("NULL OBJECT");
310 }
311
312 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
313 return ("Not a Descriptor");
314 }
315
316 return (acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE(object)]);
317}
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333static const char *acpi_gbl_ref_class_names[] = {
334 "Local",
335 "Argument",
336 "RefOf",
337 "Index",
338 "DdbHandle",
339 "Named Object",
340 "Debug"
341};
342
343const char *acpi_ut_get_reference_name(union acpi_operand_object *object)
344{
345
346 if (!object) {
347 return ("NULL Object");
348 }
349
350 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
351 return ("Not an Operand object");
352 }
353
354 if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE) {
355 return ("Not a Reference object");
356 }
357
358 if (object->reference.class > ACPI_REFCLASS_MAX) {
359 return ("Unknown Reference class");
360 }
361
362 return (acpi_gbl_ref_class_names[object->reference.class]);
363}
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379static const char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
380 "ACPI_MTX_Interpreter",
381 "ACPI_MTX_Namespace",
382 "ACPI_MTX_Tables",
383 "ACPI_MTX_Events",
384 "ACPI_MTX_Caches",
385 "ACPI_MTX_Memory",
386};
387
388const char *acpi_ut_get_mutex_name(u32 mutex_id)
389{
390
391 if (mutex_id > ACPI_MAX_MUTEX) {
392 return ("Invalid Mutex ID");
393 }
394
395 return (acpi_gbl_mutex_names[mutex_id]);
396}
397
398#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418static const char *acpi_gbl_generic_notify[ACPI_GENERIC_NOTIFY_MAX + 1] = {
419 "Bus Check",
420 "Device Check",
421 "Device Wake",
422 "Eject Request",
423 "Device Check Light",
424 "Frequency Mismatch",
425 "Bus Mode Mismatch",
426 "Power Fault",
427 "Capabilities Check",
428 "Device PLD Check",
429 "Reserved",
430 "System Locality Update",
431 "Reserved (was previously Shutdown Request)",
432
433 "System Resource Affinity Update",
434 "Heterogeneous Memory Attributes Update",
435
436 "Error Disconnect Recover"
437
438};
439
440static const char *acpi_gbl_device_notify[5] = {
441 "Status Change",
442 "Information Change",
443 "Device-Specific Change",
444 "Device-Specific Change",
445 "Reserved"
446};
447
448static const char *acpi_gbl_processor_notify[5] = {
449 "Performance Capability Change",
450 "C-State Change",
451 "Throttling Capability Change",
452 "Guaranteed Change",
453 "Minimum Excursion"
454};
455
456static const char *acpi_gbl_thermal_notify[5] = {
457 "Thermal Status Change",
458 "Thermal Trip Point Change",
459 "Thermal Device List Change",
460 "Thermal Relationship Change",
461 "Reserved"
462};
463
464const char *acpi_ut_get_notify_name(u32 notify_value, acpi_object_type type)
465{
466
467
468
469 if (notify_value <= ACPI_GENERIC_NOTIFY_MAX) {
470 return (acpi_gbl_generic_notify[notify_value]);
471 }
472
473
474
475 if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
476 return ("Reserved");
477 }
478
479
480
481 if (notify_value <= ACPI_SPECIFIC_NOTIFY_MAX) {
482 switch (type) {
483 case ACPI_TYPE_ANY:
484 case ACPI_TYPE_DEVICE:
485 return (acpi_gbl_device_notify[notify_value - 0x80]);
486
487 case ACPI_TYPE_PROCESSOR:
488 return (acpi_gbl_processor_notify[notify_value - 0x80]);
489
490 case ACPI_TYPE_THERMAL:
491 return (acpi_gbl_thermal_notify[notify_value - 0x80]);
492
493 default:
494 return ("Target object type does not support notifies");
495 }
496 }
497
498
499
500 if (notify_value <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) {
501 return ("Device-Specific");
502 }
503
504
505
506 return ("Hardware-Specific");
507}
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523static const char *acpi_gbl_argument_type[20] = {
524 "Unknown ARGP",
525 "ByteData",
526 "ByteList",
527 "CharList",
528 "DataObject",
529 "DataObjectList",
530 "DWordData",
531 "FieldList",
532 "Name",
533 "NameString",
534 "ObjectList",
535 "PackageLength",
536 "SuperName",
537 "Target",
538 "TermArg",
539 "TermList",
540 "WordData",
541 "QWordData",
542 "SimpleName",
543 "NameOrRef"
544};
545
546const char *acpi_ut_get_argument_type_name(u32 arg_type)
547{
548
549 if (arg_type > ARGP_MAX) {
550 return ("Unknown ARGP");
551 }
552
553 return (acpi_gbl_argument_type[arg_type]);
554}
555
556#endif
557
558
559
560
561
562
563
564
565
566
567
568
569
570u8 acpi_ut_valid_object_type(acpi_object_type type)
571{
572
573 if (type > ACPI_TYPE_LOCAL_MAX) {
574
575
576
577 return (FALSE);
578 }
579
580 return (TRUE);
581}
582