1 /******************************************************************************
3 * Module Name: nsdump - table dumping routines for debug
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2005, R. Byron Moore
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.
45 #include <acpi/acpi.h>
46 #include <acpi/acnamesp.h>
47 #include <acpi/acparser.h>
50 #define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsdump")
53 /* Local prototypes */
55 #ifdef ACPI_OBSOLETE_FUNCTIONS
57 acpi_ns_dump_root_devices (
61 acpi_ns_dump_one_device (
62 acpi_handle obj_handle,
69 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
70 /*******************************************************************************
72 * FUNCTION: acpi_ns_print_pathname
74 * PARAMETERS: num_segments - Number of ACPI name segments
75 * Pathname - The compressed (internal) path
79 * DESCRIPTION: Print an object's full namespace pathname
81 ******************************************************************************/
84 acpi_ns_print_pathname (
91 ACPI_FUNCTION_NAME ("ns_print_pathname");
94 if (!(acpi_dbg_level & ACPI_LV_NAMES) || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
98 /* Print the entire name */
100 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
102 while (num_segments) {
103 for (i = 0; i < 4; i++) {
104 ACPI_IS_PRINT (pathname[i]) ?
105 acpi_os_printf ("%c", pathname[i]) :
106 acpi_os_printf ("?");
109 pathname += ACPI_NAME_SIZE;
112 acpi_os_printf (".");
116 acpi_os_printf ("]\n");
120 /*******************************************************************************
122 * FUNCTION: acpi_ns_dump_pathname
124 * PARAMETERS: Handle - Object
125 * Msg - Prefix message
126 * Level - Desired debug level
127 * Component - Caller's component ID
131 * DESCRIPTION: Print an object's full namespace pathname
132 * Manages allocation/freeing of a pathname buffer
134 ******************************************************************************/
137 acpi_ns_dump_pathname (
144 ACPI_FUNCTION_TRACE ("ns_dump_pathname");
147 /* Do this only if the requested debug level and component are enabled */
149 if (!(acpi_dbg_level & level) || !(acpi_dbg_layer & component)) {
153 /* Convert handle to a full pathname and print it (with supplied message) */
155 acpi_ns_print_node_pathname (handle, msg);
156 acpi_os_printf ("\n");
161 /*******************************************************************************
163 * FUNCTION: acpi_ns_dump_one_object
165 * PARAMETERS: obj_handle - Node to be dumped
166 * Level - Nesting level of the handle
167 * Context - Passed into walk_namespace
168 * return_value - Not used
172 * DESCRIPTION: Dump a single Node
173 * This procedure is a user_function called by acpi_ns_walk_namespace.
175 ******************************************************************************/
178 acpi_ns_dump_one_object (
179 acpi_handle obj_handle,
184 struct acpi_walk_info *info = (struct acpi_walk_info *) context;
185 struct acpi_namespace_node *this_node;
186 union acpi_operand_object *obj_desc = NULL;
187 acpi_object_type obj_type;
188 acpi_object_type type;
194 ACPI_FUNCTION_NAME ("ns_dump_one_object");
197 /* Is output enabled? */
199 if (!(acpi_dbg_level & info->debug_level)) {
204 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
208 this_node = acpi_ns_map_handle_to_node (obj_handle);
209 type = this_node->type;
211 /* Check if the owner matches */
213 if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
214 (info->owner_id != this_node->owner_id)) {
218 if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
219 /* Indent the object according to the level */
221 acpi_os_printf ("%2d%*s", (u32) level - 1, (int) level * 2, " ");
223 /* Check the node type and name */
225 if (type > ACPI_TYPE_LOCAL_MAX) {
226 ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", type));
229 if (!acpi_ut_valid_acpi_name (this_node->name.integer)) {
230 ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n",
231 this_node->name.integer));
234 acpi_os_printf ("%4.4s", acpi_ut_get_node_name (this_node));
238 * Now we can print out the pertinent information
240 acpi_os_printf (" %-12s %p ",
241 acpi_ut_get_type_name (type), this_node);
243 dbg_level = acpi_dbg_level;
245 obj_desc = acpi_ns_get_attached_object (this_node);
246 acpi_dbg_level = dbg_level;
248 switch (info->display_type & ACPI_DISPLAY_MASK) {
249 case ACPI_DISPLAY_SUMMARY:
252 /* No attached object, we are done */
254 acpi_os_printf ("\n");
259 case ACPI_TYPE_PROCESSOR:
261 acpi_os_printf ("ID %X Len %.4X Addr %p\n",
262 obj_desc->processor.proc_id, obj_desc->processor.length,
263 (char *) obj_desc->processor.address);
267 case ACPI_TYPE_DEVICE:
269 acpi_os_printf ("Notify Object: %p\n", obj_desc);
273 case ACPI_TYPE_METHOD:
275 acpi_os_printf ("Args %X Len %.4X Aml %p\n",
276 (u32) obj_desc->method.param_count,
277 obj_desc->method.aml_length, obj_desc->method.aml_start);
281 case ACPI_TYPE_INTEGER:
283 acpi_os_printf ("= %8.8X%8.8X\n",
284 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
288 case ACPI_TYPE_PACKAGE:
290 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
291 acpi_os_printf ("Elements %.2X\n",
292 obj_desc->package.count);
295 acpi_os_printf ("[Length not yet evaluated]\n");
300 case ACPI_TYPE_BUFFER:
302 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
303 acpi_os_printf ("Len %.2X",
304 obj_desc->buffer.length);
306 /* Dump some of the buffer */
308 if (obj_desc->buffer.length > 0) {
309 acpi_os_printf (" =");
310 for (i = 0; (i < obj_desc->buffer.length && i < 12); i++) {
311 acpi_os_printf (" %.2hX", obj_desc->buffer.pointer[i]);
314 acpi_os_printf ("\n");
317 acpi_os_printf ("[Length not yet evaluated]\n");
322 case ACPI_TYPE_STRING:
324 acpi_os_printf ("Len %.2X ", obj_desc->string.length);
325 acpi_ut_print_string (obj_desc->string.pointer, 32);
326 acpi_os_printf ("\n");
330 case ACPI_TYPE_REGION:
332 acpi_os_printf ("[%s]",
333 acpi_ut_get_region_name (obj_desc->region.space_id));
334 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
335 acpi_os_printf (" Addr %8.8X%8.8X Len %.4X\n",
336 ACPI_FORMAT_UINT64 (obj_desc->region.address),
337 obj_desc->region.length);
340 acpi_os_printf (" [Address/Length not yet evaluated]\n");
345 case ACPI_TYPE_LOCAL_REFERENCE:
347 acpi_os_printf ("[%s]\n",
348 acpi_ps_get_opcode_name (obj_desc->reference.opcode));
352 case ACPI_TYPE_BUFFER_FIELD:
354 if (obj_desc->buffer_field.buffer_obj &&
355 obj_desc->buffer_field.buffer_obj->buffer.node) {
356 acpi_os_printf ("Buf [%4.4s]",
357 acpi_ut_get_node_name (obj_desc->buffer_field.buffer_obj->buffer.node));
362 case ACPI_TYPE_LOCAL_REGION_FIELD:
364 acpi_os_printf ("Rgn [%4.4s]",
365 acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node));
369 case ACPI_TYPE_LOCAL_BANK_FIELD:
371 acpi_os_printf ("Rgn [%4.4s] Bnk [%4.4s]",
372 acpi_ut_get_node_name (obj_desc->common_field.region_obj->region.node),
373 acpi_ut_get_node_name (obj_desc->bank_field.bank_obj->common_field.node));
377 case ACPI_TYPE_LOCAL_INDEX_FIELD:
379 acpi_os_printf ("Idx [%4.4s] Dat [%4.4s]",
380 acpi_ut_get_node_name (obj_desc->index_field.index_obj->common_field.node),
381 acpi_ut_get_node_name (obj_desc->index_field.data_obj->common_field.node));
385 case ACPI_TYPE_LOCAL_ALIAS:
386 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
388 acpi_os_printf ("Target %4.4s (%p)\n",
389 acpi_ut_get_node_name (obj_desc), obj_desc);
394 acpi_os_printf ("Object %p\n", obj_desc);
398 /* Common field handling */
401 case ACPI_TYPE_BUFFER_FIELD:
402 case ACPI_TYPE_LOCAL_REGION_FIELD:
403 case ACPI_TYPE_LOCAL_BANK_FIELD:
404 case ACPI_TYPE_LOCAL_INDEX_FIELD:
406 acpi_os_printf (" Off %.3X Len %.2X Acc %.2hd\n",
407 (obj_desc->common_field.base_byte_offset * 8)
408 + obj_desc->common_field.start_field_bit_offset,
409 obj_desc->common_field.bit_length,
410 obj_desc->common_field.access_byte_width);
419 case ACPI_DISPLAY_OBJECTS:
421 acpi_os_printf ("O:%p", obj_desc);
423 /* No attached object, we are done */
425 acpi_os_printf ("\n");
429 acpi_os_printf ("(R%d)", obj_desc->common.reference_count);
432 case ACPI_TYPE_METHOD:
434 /* Name is a Method and its AML offset/length are set */
436 acpi_os_printf (" M:%p-%X\n", obj_desc->method.aml_start,
437 obj_desc->method.aml_length);
440 case ACPI_TYPE_INTEGER:
442 acpi_os_printf (" I:%8.8X8.8%X\n",
443 ACPI_FORMAT_UINT64 (obj_desc->integer.value));
446 case ACPI_TYPE_STRING:
448 acpi_os_printf (" S:%p-%X\n", obj_desc->string.pointer,
449 obj_desc->string.length);
452 case ACPI_TYPE_BUFFER:
454 acpi_os_printf (" B:%p-%X\n", obj_desc->buffer.pointer,
455 obj_desc->buffer.length);
460 acpi_os_printf ("\n");
467 acpi_os_printf ("\n");
471 /* If debug turned off, done */
473 if (!(acpi_dbg_level & ACPI_LV_VALUES)) {
478 /* If there is an attached object, display it */
480 dbg_level = acpi_dbg_level;
482 obj_desc = acpi_ns_get_attached_object (this_node);
483 acpi_dbg_level = dbg_level;
485 /* Dump attached objects */
488 obj_type = ACPI_TYPE_INVALID;
489 acpi_os_printf ("Attached Object %p: ", obj_desc);
491 /* Decode the type of attached object and dump the contents */
493 switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
494 case ACPI_DESC_TYPE_NAMED:
496 acpi_os_printf ("(Ptr to Node)\n");
497 bytes_to_dump = sizeof (struct acpi_namespace_node);
498 ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump);
501 case ACPI_DESC_TYPE_OPERAND:
503 obj_type = ACPI_GET_OBJECT_TYPE (obj_desc);
505 if (obj_type > ACPI_TYPE_LOCAL_MAX) {
506 acpi_os_printf ("(Ptr to ACPI Object type %X [UNKNOWN])\n",
511 acpi_os_printf ("(Ptr to ACPI Object type %X [%s])\n",
512 obj_type, acpi_ut_get_type_name (obj_type));
513 bytes_to_dump = sizeof (union acpi_operand_object);
516 ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump);
524 /* If value is NOT an internal object, we are done */
526 if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) != ACPI_DESC_TYPE_OPERAND) {
531 * Valid object, get the pointer to next level, if any
534 case ACPI_TYPE_BUFFER:
535 case ACPI_TYPE_STRING:
537 * NOTE: takes advantage of common fields between string/buffer
539 bytes_to_dump = obj_desc->string.length;
540 obj_desc = (void *) obj_desc->string.pointer;
541 acpi_os_printf ( "(Buffer/String pointer %p length %X)\n",
542 obj_desc, bytes_to_dump);
543 ACPI_DUMP_BUFFER (obj_desc, bytes_to_dump);
546 case ACPI_TYPE_BUFFER_FIELD:
547 obj_desc = (union acpi_operand_object *) obj_desc->buffer_field.buffer_obj;
550 case ACPI_TYPE_PACKAGE:
551 obj_desc = (void *) obj_desc->package.elements;
554 case ACPI_TYPE_METHOD:
555 obj_desc = (void *) obj_desc->method.aml_start;
558 case ACPI_TYPE_LOCAL_REGION_FIELD:
559 obj_desc = (void *) obj_desc->field.region_obj;
562 case ACPI_TYPE_LOCAL_BANK_FIELD:
563 obj_desc = (void *) obj_desc->bank_field.region_obj;
566 case ACPI_TYPE_LOCAL_INDEX_FIELD:
567 obj_desc = (void *) obj_desc->index_field.index_obj;
574 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
578 acpi_os_printf ("\n");
583 #ifdef ACPI_FUTURE_USAGE
584 /*******************************************************************************
586 * FUNCTION: acpi_ns_dump_objects
588 * PARAMETERS: Type - Object type to be dumped
589 * display_type - 0 or ACPI_DISPLAY_SUMMARY
590 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
591 * for an effectively unlimited depth.
592 * owner_id - Dump only objects owned by this ID. Use
593 * ACPI_UINT32_MAX to match all owners.
594 * start_handle - Where in namespace to start/end search
598 * DESCRIPTION: Dump typed objects within the loaded namespace.
599 * Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
601 ******************************************************************************/
604 acpi_ns_dump_objects (
605 acpi_object_type type,
608 acpi_owner_id owner_id,
609 acpi_handle start_handle)
611 struct acpi_walk_info info;
614 ACPI_FUNCTION_ENTRY ();
617 info.debug_level = ACPI_LV_TABLES;
618 info.owner_id = owner_id;
619 info.display_type = display_type;
621 (void) acpi_ns_walk_namespace (type, start_handle, max_depth,
622 ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object,
623 (void *) &info, NULL);
625 #endif /* ACPI_FUTURE_USAGE */
628 /*******************************************************************************
630 * FUNCTION: acpi_ns_dump_entry
632 * PARAMETERS: Handle - Node to be dumped
633 * debug_level - Output level
637 * DESCRIPTION: Dump a single Node
639 ******************************************************************************/
646 struct acpi_walk_info info;
649 ACPI_FUNCTION_ENTRY ();
652 info.debug_level = debug_level;
653 info.owner_id = ACPI_OWNER_ID_MAX;
654 info.display_type = ACPI_DISPLAY_SUMMARY;
656 (void) acpi_ns_dump_one_object (handle, 1, &info, NULL);
660 #ifdef ACPI_ASL_COMPILER
661 /*******************************************************************************
663 * FUNCTION: acpi_ns_dump_tables
665 * PARAMETERS: search_base - Root of subtree to be dumped, or
666 * NS_ALL to dump the entire namespace
667 * max_depth - Maximum depth of dump. Use INT_MAX
668 * for an effectively unlimited depth.
672 * DESCRIPTION: Dump the name space, or a portion of it.
674 ******************************************************************************/
677 acpi_ns_dump_tables (
678 acpi_handle search_base,
681 acpi_handle search_handle = search_base;
684 ACPI_FUNCTION_TRACE ("ns_dump_tables");
687 if (!acpi_gbl_root_node) {
689 * If the name space has not been initialized,
690 * there is nothing to dump.
692 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
696 if (ACPI_NS_ALL == search_base) {
697 /* Entire namespace */
699 search_handle = acpi_gbl_root_node;
700 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
703 acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, max_depth,
704 ACPI_OWNER_ID_MAX, search_handle);
707 #endif /* _ACPI_ASL_COMPILER */
708 #endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */