aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace/nsdump.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/namespace/nsdump.c')
-rw-r--r--drivers/acpi/namespace/nsdump.c673
1 files changed, 673 insertions, 0 deletions
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
new file mode 100644
index 000000000000..1f6af3eb6c91
--- /dev/null
+++ b/drivers/acpi/namespace/nsdump.c
@@ -0,0 +1,673 @@
1/******************************************************************************
2 *
3 * Module Name: nsdump - table dumping routines for debug
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
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
45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h>
47#include <acpi/acparser.h>
48
49
50#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsdump")
52
53
54#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
55
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_ns_print_pathname
59 *
60 * PARAMETERS: num_segment - Number of ACPI name segments
61 * Pathname - The compressed (internal) path
62 *
63 * DESCRIPTION: Print an object's full namespace pathname
64 *
65 ******************************************************************************/
66
67void
68acpi_ns_print_pathname (
69 u32 num_segments,
70 char *pathname)
71{
72 ACPI_FUNCTION_NAME ("ns_print_pathname");
73
74
75 if (!(acpi_dbg_level & ACPI_LV_NAMES) || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
76 return;
77 }
78
79 /* Print the entire name */
80
81 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
82
83 while (num_segments) {
84 acpi_os_printf ("%4.4s", pathname);
85 pathname += ACPI_NAME_SIZE;
86
87 num_segments--;
88 if (num_segments) {
89 acpi_os_printf (".");
90 }
91 }
92
93 acpi_os_printf ("]\n");
94}
95
96
97/*******************************************************************************
98 *
99 * FUNCTION: acpi_ns_dump_pathname
100 *
101 * PARAMETERS: Handle - Object
102 * Msg - Prefix message
103 * Level - Desired debug level
104 * Component - Caller's component ID
105 *
106 * DESCRIPTION: Print an object's full namespace pathname
107 * Manages allocation/freeing of a pathname buffer
108 *
109 ******************************************************************************/
110
111void
112acpi_ns_dump_pathname (
113 acpi_handle handle,
114 char *msg,
115 u32 level,
116 u32 component)
117{
118
119 ACPI_FUNCTION_TRACE ("ns_dump_pathname");
120
121
122 /* Do this only if the requested debug level and component are enabled */
123
124 if (!(acpi_dbg_level & level) || !(acpi_dbg_layer & component)) {
125 return_VOID;
126 }
127
128 /* Convert handle to a full pathname and print it (with supplied message) */
129
130 acpi_ns_print_node_pathname (handle, msg);
131 acpi_os_printf ("\n");
132 return_VOID;
133}
134
135
136/*******************************************************************************
137 *
138 * FUNCTION: acpi_ns_dump_one_object
139 *
140 * PARAMETERS: Handle - Node to be dumped
141 * Level - Nesting level of the handle
142 * Context - Passed into walk_namespace
143 *
144 * DESCRIPTION: Dump a single Node
145 * This procedure is a user_function called by acpi_ns_walk_namespace.
146 *
147 ******************************************************************************/
148
149acpi_status
150acpi_ns_dump_one_object (
151 acpi_handle obj_handle,
152 u32 level,
153 void *context,
154 void **return_value)
155{
156 struct acpi_walk_info *info = (struct acpi_walk_info *) context;
157 struct acpi_namespace_node *this_node;
158 union acpi_operand_object *obj_desc = NULL;
159 acpi_object_type obj_type;
160 acpi_object_type type;
161 u32 bytes_to_dump;
162 u32 dbg_level;
163 u32 i;
164
165
166 ACPI_FUNCTION_NAME ("ns_dump_one_object");
167
168
169 /* Is output enabled? */
170
171 if (!(acpi_dbg_level & info->debug_level)) {
172 return (AE_OK);
173 }
174
175 if (!obj_handle) {
176 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
177 return (AE_OK);
178 }
179
180 this_node = acpi_ns_map_handle_to_node (obj_handle);
181 type = this_node->type;
182
183 /* Check if the owner matches */
184
185 if ((info->owner_id != ACPI_UINT32_MAX) &&
186 (info->owner_id != this_node->owner_id)) {
187 return (AE_OK);
188 }
189
190 /* Indent the object according to the level */
191
192 acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " ");
193
194 /* Check the node type and name */
195
196 if (type > ACPI_TYPE_LOCAL_MAX) {
197 ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type));
198 }
199
200 if (!acpi_ut_valid_acpi_name (this_node->name.integer)) {
201 ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n",
202 this_node->name.integer));
203 }
204
205 /*
206 * Now we can print out the pertinent information
207 */
208 acpi_os_printf ("%4.4s %-12s %p ",
209 acpi_ut_get_node_name (this_node), acpi_ut_get_type_name (type), this_node);
210
211 dbg_level = acpi_dbg_level;
212 acpi_dbg_level = 0;
213 obj_desc = acpi_ns_get_attached_object (this_node);
214 acpi_dbg_level = dbg_level;
215
216 switch (info->display_type) {
217 case ACPI_DISPLAY_SUMMARY:
218
219 if (!obj_desc) {
220 /* No attached object, we are done */
221
222 acpi_os_printf ("\n");
223 return (AE_OK);
224 }
225
226 switch (type) {
227 case ACPI_TYPE_PROCESSOR:
228
229 acpi_os_printf ("ID %X Len %.4X Addr %p\n",
230 obj_desc->processor.proc_id, obj_desc->processor.length,
231 (char *) obj_desc->processor.address);
232 break;
233
234
235 case ACPI_TYPE_DEVICE:
236
237 acpi_os_printf ("Notify Object: %p\n", obj_desc);
238 break;
239
240
241 case ACPI_TYPE_METHOD:
242
243 acpi_os_printf ("Args %X Len %.4X Aml %p\n",
244 (u32) obj_desc->method.param_count,
245 obj_desc->method.aml_length, obj_desc->method.aml_start);
246 break;
247
248
249 case ACPI_TYPE_INTEGER:
250
251 acpi_os_printf ("= %8.8X%8.8X\n",
252 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
253 break;
254
255
256 case ACPI_TYPE_PACKAGE:
257
258 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
259 acpi_os_printf ("Elements %.2X\n",
260 obj_desc->package.count);
261 }
262 else {
263 acpi_os_printf ("[Length not yet evaluated]\n");
264 }
265 break;
266
267
268 case ACPI_TYPE_BUFFER:
269
270 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
271 acpi_os_printf ("Len %.2X",
272 obj_desc->buffer.length);
273
274 /* Dump some of the buffer */
275
276 if (obj_desc->buffer.length > 0) {
277 acpi_os_printf (" =");
278 for (i = 0; (i < obj_desc->buffer.length && i < 12); i++) {
279 acpi_os_printf (" %.2hX", obj_desc->buffer.pointer[i]);
280 }
281 }
282 acpi_os_printf ("\n");
283 }
284 else {
285 acpi_os_printf ("[Length not yet evaluated]\n");
286 }
287 break;
288
289
290 case ACPI_TYPE_STRING:
291
292 acpi_os_printf ("Len %.2X ", obj_desc->string.length);
293 acpi_ut_print_string (obj_desc->string.pointer, 32);
294 acpi_os_printf ("\n");
295 break;
296
297
298 case ACPI_TYPE_REGION:
299
300 acpi_os_printf ("[%s]",
301 acpi_ut_get_region_name (obj_desc->region.space_id));
302 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
303 acpi_os_printf (" Addr %8.8X%8.8X Len %.4X\n",
304 ACPI_FORMAT_UINT64 (obj_desc->region.address),
305 obj_desc->region.length);
306 }
307 else {
308 acpi_os_printf (" [Address/Length not yet evaluated]\n");
309 }
310 break;
311
312
313 case ACPI_TYPE_LOCAL_REFERENCE:
314
315 acpi_os_printf ("[%s]\n",
316 acpi_ps_get_opcode_name (obj_desc->reference.opcode));
317 break;
318
319
320 case ACPI_TYPE_BUFFER_FIELD:
321
322 if (obj_desc->buffer_field.buffer_obj &&
323 obj_desc->buffer_field.buffer_obj->buffer.node) {
324 acpi_os_printf ("Buf [%4.4s]",
325 acpi_ut_get_node_name (obj_desc->buffer_field.buffer_obj->buffer.node));
326 }
327 break;
328
329
330 case ACPI_TYPE_LOCAL_REGION_FIELD:
331
332 acpi_os_printf ("Rgn [%4.4s]",
333 acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node));
334 break;
335
336
337 case ACPI_TYPE_LOCAL_BANK_FIELD:
338
339 acpi_os_printf ("Rgn [%4.4s] Bnk [%4.4s]",
340 acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node),
341 acpi_ut_get_node_name (obj_desc->bank_field.bank_obj->common_field.node));
342 break;
343
344
345 case ACPI_TYPE_LOCAL_INDEX_FIELD:
346
347 acpi_os_printf ("Idx [%4.4s] Dat [%4.4s]",
348 acpi_ut_get_node_name (obj_desc->index_field.index_obj->common_field.node),
349 acpi_ut_get_node_name (obj_desc->index_field.data_obj->common_field.node));
350 break;
351
352
353 case ACPI_TYPE_LOCAL_ALIAS:
354 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
355
356 acpi_os_printf ("Target %4.4s (%p)\n",
357 acpi_ut_get_node_name (obj_desc), obj_desc);
358 break;
359
360 default:
361
362 acpi_os_printf ("Object %p\n", obj_desc);
363 break;
364 }
365
366 /* Common field handling */
367
368 switch (type) {
369 case ACPI_TYPE_BUFFER_FIELD:
370 case ACPI_TYPE_LOCAL_REGION_FIELD:
371 case ACPI_TYPE_LOCAL_BANK_FIELD:
372 case ACPI_TYPE_LOCAL_INDEX_FIELD:
373
374 acpi_os_printf (" Off %.3X Len %.2X Acc %.2hd\n",
375 (obj_desc->common_field.base_byte_offset * 8)
376 + obj_desc->common_field.start_field_bit_offset,
377 obj_desc->common_field.bit_length,
378 obj_desc->common_field.access_byte_width);
379 break;
380
381 default:
382 break;
383 }
384 break;
385
386
387 case ACPI_DISPLAY_OBJECTS:
388
389 acpi_os_printf ("O:%p", obj_desc);
390 if (!obj_desc) {
391 /* No attached object, we are done */
392
393 acpi_os_printf ("\n");
394 return (AE_OK);
395 }
396
397 acpi_os_printf ("(R%d)",
398 obj_desc->common.reference_count);
399
400 switch (type) {
401 case ACPI_TYPE_METHOD:
402
403 /* Name is a Method and its AML offset/length are set */
404
405 acpi_os_printf (" M:%p-%X\n", obj_desc->method.aml_start,
406 obj_desc->method.aml_length);
407 break;
408
409 case ACPI_TYPE_INTEGER:
410
411 acpi_os_printf (" I:%8.8X8.8%X\n",
412 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
413 break;
414
415 case ACPI_TYPE_STRING:
416
417 acpi_os_printf (" S:%p-%X\n", obj_desc->string.pointer,
418 obj_desc->string.length);
419 break;
420
421 case ACPI_TYPE_BUFFER:
422
423 acpi_os_printf (" B:%p-%X\n", obj_desc->buffer.pointer,
424 obj_desc->buffer.length);
425 break;
426
427 default:
428
429 acpi_os_printf ("\n");
430 break;
431 }
432 break;
433
434
435 default:
436 acpi_os_printf ("\n");
437 break;
438 }
439
440 /* If debug turned off, done */
441
442 if (!(acpi_dbg_level & ACPI_LV_VALUES)) {
443 return (AE_OK);
444 }
445
446
447 /* If there is an attached object, display it */
448
449 dbg_level = acpi_dbg_level;
450 acpi_dbg_level = 0;
451 obj_desc = acpi_ns_get_attached_object (this_node);
452 acpi_dbg_level = dbg_level;
453
454 /* Dump attached objects */
455
456 while (obj_desc) {
457 obj_type = ACPI_TYPE_INVALID;
458 acpi_os_printf (" Attached Object %p: ", obj_desc);
459
460 /* Decode the type of attached object and dump the contents */
461
462 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
463 case ACPI_DESC_TYPE_NAMED:
464
465 acpi_os_printf ("(Ptr to Node)\n");
466 bytes_to_dump = sizeof (struct acpi_namespace_node);
467 break;
468
469
470 case ACPI_DESC_TYPE_OPERAND:
471
472 obj_type = ACPI_GET_OBJECT_TYPE (obj_desc);
473
474 if (obj_type > ACPI_TYPE_LOCAL_MAX) {
475 acpi_os_printf ("(Ptr to ACPI Object type %X [UNKNOWN])\n",
476 obj_type);
477 bytes_to_dump = 32;
478 }
479 else {
480 acpi_os_printf ("(Ptr to ACPI Object type %s, %X)\n",
481 acpi_ut_get_type_name (obj_type), obj_type);
482 bytes_to_dump = sizeof (union acpi_operand_object);
483 }
484 break;
485
486
487 default:
488
489 acpi_os_printf (
490 "(String or Buffer ptr - not an object descriptor) [%s]\n",
491 acpi_ut_get_descriptor_name (obj_desc));
492 bytes_to_dump = 16;
493 break;
494 }
495
496 ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump);
497
498 /* If value is NOT an internal object, we are done */
499
500 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
501 goto cleanup;
502 }
503
504 /*
505 * Valid object, get the pointer to next level, if any
506 */
507 switch (obj_type) {
508 case ACPI_TYPE_STRING:
509 obj_desc = (void *) obj_desc->string.pointer;
510 break;
511
512 case ACPI_TYPE_BUFFER:
513 obj_desc = (void *) obj_desc->buffer.pointer;
514 break;
515
516 case ACPI_TYPE_BUFFER_FIELD:
517 obj_desc = (union acpi_operand_object *) obj_desc->buffer_field.buffer_obj;
518 break;
519
520 case ACPI_TYPE_PACKAGE:
521 obj_desc = (void *) obj_desc->package.elements;
522 break;
523
524 case ACPI_TYPE_METHOD:
525 obj_desc = (void *) obj_desc->method.aml_start;
526 break;
527
528 case ACPI_TYPE_LOCAL_REGION_FIELD:
529 obj_desc = (void *) obj_desc->field.region_obj;
530 break;
531
532 case ACPI_TYPE_LOCAL_BANK_FIELD:
533 obj_desc = (void *) obj_desc->bank_field.region_obj;
534 break;
535
536 case ACPI_TYPE_LOCAL_INDEX_FIELD:
537 obj_desc = (void *) obj_desc->index_field.index_obj;
538 break;
539
540 default:
541 goto cleanup;
542 }
543
544 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
545 }
546
547cleanup:
548 acpi_os_printf ("\n");
549 return (AE_OK);
550}
551
552
553#ifdef ACPI_FUTURE_USAGE
554
555/*******************************************************************************
556 *
557 * FUNCTION: acpi_ns_dump_objects
558 *
559 * PARAMETERS: Type - Object type to be dumped
560 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
561 * for an effectively unlimited depth.
562 * owner_id - Dump only objects owned by this ID. Use
563 * ACPI_UINT32_MAX to match all owners.
564 * start_handle - Where in namespace to start/end search
565 *
566 * DESCRIPTION: Dump typed objects within the loaded namespace.
567 * Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
568 *
569 ******************************************************************************/
570
571void
572acpi_ns_dump_objects (
573 acpi_object_type type,
574 u8 display_type,
575 u32 max_depth,
576 u32 owner_id,
577 acpi_handle start_handle)
578{
579 struct acpi_walk_info info;
580
581
582 ACPI_FUNCTION_ENTRY ();
583
584
585 info.debug_level = ACPI_LV_TABLES;
586 info.owner_id = owner_id;
587 info.display_type = display_type;
588
589 (void) acpi_ns_walk_namespace (type, start_handle, max_depth,
590 ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object,
591 (void *) &info, NULL);
592}
593
594
595/*******************************************************************************
596 *
597 * FUNCTION: acpi_ns_dump_tables
598 *
599 * PARAMETERS: search_base - Root of subtree to be dumped, or
600 * NS_ALL to dump the entire namespace
601 * max_depth - Maximum depth of dump. Use INT_MAX
602 * for an effectively unlimited depth.
603 *
604 * DESCRIPTION: Dump the name space, or a portion of it.
605 *
606 ******************************************************************************/
607
608void
609acpi_ns_dump_tables (
610 acpi_handle search_base,
611 u32 max_depth)
612{
613 acpi_handle search_handle = search_base;
614
615
616 ACPI_FUNCTION_TRACE ("ns_dump_tables");
617
618
619 if (!acpi_gbl_root_node) {
620 /*
621 * If the name space has not been initialized,
622 * there is nothing to dump.
623 */
624 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
625 return_VOID;
626 }
627
628 if (ACPI_NS_ALL == search_base) {
629 /* entire namespace */
630
631 search_handle = acpi_gbl_root_node;
632 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
633 }
634
635 acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
636 ACPI_UINT32_MAX, search_handle);
637 return_VOID;
638}
639
640#endif /* ACPI_FUTURE_USAGE */
641
642
643/*******************************************************************************
644 *
645 * FUNCTION: acpi_ns_dump_entry
646 *
647 * PARAMETERS: Handle - Node to be dumped
648 * debug_level - Output level
649 *
650 * DESCRIPTION: Dump a single Node
651 *
652 ******************************************************************************/
653
654void
655acpi_ns_dump_entry (
656 acpi_handle handle,
657 u32 debug_level)
658{
659 struct acpi_walk_info info;
660
661
662 ACPI_FUNCTION_ENTRY ();
663
664
665 info.debug_level = debug_level;
666 info.owner_id = ACPI_UINT32_MAX;
667 info.display_type = ACPI_DISPLAY_SUMMARY;
668
669 (void) acpi_ns_dump_one_object (handle, 1, &info, NULL);
670}
671
672#endif
673