1 /******************************************************************************
3 * Module Name: nsdump - table dumping routines for debug
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2008, Intel Corp.
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.
44 #include <acpi/acpi.h>
45 #include <acpi/acnamesp.h>
47 #define _COMPONENT ACPI_NAMESPACE
48 ACPI_MODULE_NAME("nsdump")
50 /* Local prototypes */
51 #ifdef ACPI_OBSOLETE_FUNCTIONS
52 void acpi_ns_dump_root_devices(void);
55 acpi_ns_dump_one_device(acpi_handle obj_handle,
56 u32 level, void *context, void **return_value);
59 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
60 /*******************************************************************************
62 * FUNCTION: acpi_ns_print_pathname
64 * PARAMETERS: num_segments - Number of ACPI name segments
65 * Pathname - The compressed (internal) path
69 * DESCRIPTION: Print an object's full namespace pathname
71 ******************************************************************************/
73 void acpi_ns_print_pathname(u32 num_segments, char *pathname)
77 ACPI_FUNCTION_NAME(ns_print_pathname);
79 if (!(acpi_dbg_level & ACPI_LV_NAMES)
80 || !(acpi_dbg_layer & ACPI_NAMESPACE)) {
84 /* Print the entire name */
86 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "["));
88 while (num_segments) {
89 for (i = 0; i < 4; i++) {
90 ACPI_IS_PRINT(pathname[i]) ?
91 acpi_os_printf("%c", pathname[i]) :
95 pathname += ACPI_NAME_SIZE;
102 acpi_os_printf("]\n");
105 /*******************************************************************************
107 * FUNCTION: acpi_ns_dump_pathname
109 * PARAMETERS: Handle - Object
110 * Msg - Prefix message
111 * Level - Desired debug level
112 * Component - Caller's component ID
116 * DESCRIPTION: Print an object's full namespace pathname
117 * Manages allocation/freeing of a pathname buffer
119 ******************************************************************************/
122 acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
125 ACPI_FUNCTION_TRACE(ns_dump_pathname);
127 /* Do this only if the requested debug level and component are enabled */
129 if (!(acpi_dbg_level & level) || !(acpi_dbg_layer & component)) {
133 /* Convert handle to a full pathname and print it (with supplied message) */
135 acpi_ns_print_node_pathname(handle, msg);
136 acpi_os_printf("\n");
140 /*******************************************************************************
142 * FUNCTION: acpi_ns_dump_one_object
144 * PARAMETERS: obj_handle - Node to be dumped
145 * Level - Nesting level of the handle
146 * Context - Passed into walk_namespace
147 * return_value - Not used
151 * DESCRIPTION: Dump a single Node
152 * This procedure is a user_function called by acpi_ns_walk_namespace.
154 ******************************************************************************/
157 acpi_ns_dump_one_object(acpi_handle obj_handle,
158 u32 level, void *context, void **return_value)
160 struct acpi_walk_info *info = (struct acpi_walk_info *)context;
161 struct acpi_namespace_node *this_node;
162 union acpi_operand_object *obj_desc = NULL;
163 acpi_object_type obj_type;
164 acpi_object_type type;
169 ACPI_FUNCTION_NAME(ns_dump_one_object);
171 /* Is output enabled? */
173 if (!(acpi_dbg_level & info->debug_level)) {
178 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Null object handle\n"));
182 this_node = acpi_ns_map_handle_to_node(obj_handle);
183 type = this_node->type;
185 /* Check if the owner matches */
187 if ((info->owner_id != ACPI_OWNER_ID_MAX) &&
188 (info->owner_id != this_node->owner_id)) {
192 if (!(info->display_type & ACPI_DISPLAY_SHORT)) {
194 /* Indent the object according to the level */
196 acpi_os_printf("%2d%*s", (u32) level - 1, (int)level * 2, " ");
198 /* Check the node type and name */
200 if (type > ACPI_TYPE_LOCAL_MAX) {
201 ACPI_WARNING((AE_INFO, "Invalid ACPI Object Type %08X",
205 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
206 this_node->name.integer =
207 acpi_ut_repair_name(this_node->name.ascii);
209 ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X",
210 this_node->name.integer));
213 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
217 * Now we can print out the pertinent information
219 acpi_os_printf(" %-12s %p %2.2X ",
220 acpi_ut_get_type_name(type), this_node,
221 this_node->owner_id);
223 dbg_level = acpi_dbg_level;
225 obj_desc = acpi_ns_get_attached_object(this_node);
226 acpi_dbg_level = dbg_level;
228 /* Temp nodes are those nodes created by a control method */
230 if (this_node->flags & ANOBJ_TEMPORARY) {
231 acpi_os_printf("(T) ");
234 switch (info->display_type & ACPI_DISPLAY_MASK) {
235 case ACPI_DISPLAY_SUMMARY:
239 /* No attached object, we are done */
241 acpi_os_printf("\n");
246 case ACPI_TYPE_PROCESSOR:
248 acpi_os_printf("ID %X Len %.4X Addr %p\n",
249 obj_desc->processor.proc_id,
250 obj_desc->processor.length,
256 case ACPI_TYPE_DEVICE:
258 acpi_os_printf("Notify Object: %p\n", obj_desc);
261 case ACPI_TYPE_METHOD:
263 acpi_os_printf("Args %X Len %.4X Aml %p\n",
264 (u32) obj_desc->method.param_count,
265 obj_desc->method.aml_length,
266 obj_desc->method.aml_start);
269 case ACPI_TYPE_INTEGER:
271 acpi_os_printf("= %8.8X%8.8X\n",
272 ACPI_FORMAT_UINT64(obj_desc->integer.
276 case ACPI_TYPE_PACKAGE:
278 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
279 acpi_os_printf("Elements %.2X\n",
280 obj_desc->package.count);
282 acpi_os_printf("[Length not yet evaluated]\n");
286 case ACPI_TYPE_BUFFER:
288 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
289 acpi_os_printf("Len %.2X",
290 obj_desc->buffer.length);
292 /* Dump some of the buffer */
294 if (obj_desc->buffer.length > 0) {
295 acpi_os_printf(" =");
297 (i < obj_desc->buffer.length
299 acpi_os_printf(" %.2hX",
304 acpi_os_printf("\n");
306 acpi_os_printf("[Length not yet evaluated]\n");
310 case ACPI_TYPE_STRING:
312 acpi_os_printf("Len %.2X ", obj_desc->string.length);
313 acpi_ut_print_string(obj_desc->string.pointer, 32);
314 acpi_os_printf("\n");
317 case ACPI_TYPE_REGION:
319 acpi_os_printf("[%s]",
320 acpi_ut_get_region_name(obj_desc->region.
322 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
323 acpi_os_printf(" Addr %8.8X%8.8X Len %.4X\n",
324 ACPI_FORMAT_NATIVE_UINT
325 (obj_desc->region.address),
326 obj_desc->region.length);
329 (" [Address/Length not yet evaluated]\n");
333 case ACPI_TYPE_LOCAL_REFERENCE:
335 acpi_os_printf("[%s]\n",
336 acpi_ut_get_reference_name(obj_desc));
339 case ACPI_TYPE_BUFFER_FIELD:
341 if (obj_desc->buffer_field.buffer_obj &&
342 obj_desc->buffer_field.buffer_obj->buffer.node) {
343 acpi_os_printf("Buf [%4.4s]",
344 acpi_ut_get_node_name(obj_desc->
352 case ACPI_TYPE_LOCAL_REGION_FIELD:
354 acpi_os_printf("Rgn [%4.4s]",
355 acpi_ut_get_node_name(obj_desc->
361 case ACPI_TYPE_LOCAL_BANK_FIELD:
363 acpi_os_printf("Rgn [%4.4s] Bnk [%4.4s]",
364 acpi_ut_get_node_name(obj_desc->
368 acpi_ut_get_node_name(obj_desc->
375 case ACPI_TYPE_LOCAL_INDEX_FIELD:
377 acpi_os_printf("Idx [%4.4s] Dat [%4.4s]",
378 acpi_ut_get_node_name(obj_desc->
382 acpi_ut_get_node_name(obj_desc->
389 case ACPI_TYPE_LOCAL_ALIAS:
390 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
392 acpi_os_printf("Target %4.4s (%p)\n",
393 acpi_ut_get_node_name(obj_desc),
399 acpi_os_printf("Object %p\n", obj_desc);
403 /* Common field handling */
406 case ACPI_TYPE_BUFFER_FIELD:
407 case ACPI_TYPE_LOCAL_REGION_FIELD:
408 case ACPI_TYPE_LOCAL_BANK_FIELD:
409 case ACPI_TYPE_LOCAL_INDEX_FIELD:
411 acpi_os_printf(" Off %.3X Len %.2X Acc %.2hd\n",
412 (obj_desc->common_field.
413 base_byte_offset * 8)
415 obj_desc->common_field.
416 start_field_bit_offset,
417 obj_desc->common_field.bit_length,
418 obj_desc->common_field.
427 case ACPI_DISPLAY_OBJECTS:
429 acpi_os_printf("O:%p", obj_desc);
432 /* No attached object, we are done */
434 acpi_os_printf("\n");
438 acpi_os_printf("(R%d)", obj_desc->common.reference_count);
441 case ACPI_TYPE_METHOD:
443 /* Name is a Method and its AML offset/length are set */
445 acpi_os_printf(" M:%p-%X\n", obj_desc->method.aml_start,
446 obj_desc->method.aml_length);
449 case ACPI_TYPE_INTEGER:
451 acpi_os_printf(" I:%8.8X8.8%X\n",
452 ACPI_FORMAT_UINT64(obj_desc->integer.
456 case ACPI_TYPE_STRING:
458 acpi_os_printf(" S:%p-%X\n", obj_desc->string.pointer,
459 obj_desc->string.length);
462 case ACPI_TYPE_BUFFER:
464 acpi_os_printf(" B:%p-%X\n", obj_desc->buffer.pointer,
465 obj_desc->buffer.length);
470 acpi_os_printf("\n");
476 acpi_os_printf("\n");
480 /* If debug turned off, done */
482 if (!(acpi_dbg_level & ACPI_LV_VALUES)) {
486 /* If there is an attached object, display it */
488 dbg_level = acpi_dbg_level;
490 obj_desc = acpi_ns_get_attached_object(this_node);
491 acpi_dbg_level = dbg_level;
493 /* Dump attached objects */
496 obj_type = ACPI_TYPE_INVALID;
497 acpi_os_printf("Attached Object %p: ", obj_desc);
499 /* Decode the type of attached object and dump the contents */
501 switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) {
502 case ACPI_DESC_TYPE_NAMED:
504 acpi_os_printf("(Ptr to Node)\n");
505 bytes_to_dump = sizeof(struct acpi_namespace_node);
506 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
509 case ACPI_DESC_TYPE_OPERAND:
511 obj_type = ACPI_GET_OBJECT_TYPE(obj_desc);
513 if (obj_type > ACPI_TYPE_LOCAL_MAX) {
515 ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
520 ("(Pointer to ACPI Object type %.2X [%s])\n",
521 obj_type, acpi_ut_get_type_name(obj_type));
523 sizeof(union acpi_operand_object);
526 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
534 /* If value is NOT an internal object, we are done */
536 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
537 ACPI_DESC_TYPE_OPERAND) {
542 * Valid object, get the pointer to next level, if any
545 case ACPI_TYPE_BUFFER:
546 case ACPI_TYPE_STRING:
548 * NOTE: takes advantage of common fields between string/buffer
550 bytes_to_dump = obj_desc->string.length;
551 obj_desc = (void *)obj_desc->string.pointer;
552 acpi_os_printf("(Buffer/String pointer %p length %X)\n",
553 obj_desc, bytes_to_dump);
554 ACPI_DUMP_BUFFER(obj_desc, bytes_to_dump);
557 case ACPI_TYPE_BUFFER_FIELD:
559 (union acpi_operand_object *)obj_desc->buffer_field.
563 case ACPI_TYPE_PACKAGE:
564 obj_desc = (void *)obj_desc->package.elements;
567 case ACPI_TYPE_METHOD:
568 obj_desc = (void *)obj_desc->method.aml_start;
571 case ACPI_TYPE_LOCAL_REGION_FIELD:
572 obj_desc = (void *)obj_desc->field.region_obj;
575 case ACPI_TYPE_LOCAL_BANK_FIELD:
576 obj_desc = (void *)obj_desc->bank_field.region_obj;
579 case ACPI_TYPE_LOCAL_INDEX_FIELD:
580 obj_desc = (void *)obj_desc->index_field.index_obj;
587 obj_type = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
591 acpi_os_printf("\n");
595 #ifdef ACPI_FUTURE_USAGE
596 /*******************************************************************************
598 * FUNCTION: acpi_ns_dump_objects
600 * PARAMETERS: Type - Object type to be dumped
601 * display_type - 0 or ACPI_DISPLAY_SUMMARY
602 * max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
603 * for an effectively unlimited depth.
604 * owner_id - Dump only objects owned by this ID. Use
605 * ACPI_UINT32_MAX to match all owners.
606 * start_handle - Where in namespace to start/end search
610 * DESCRIPTION: Dump typed objects within the loaded namespace.
611 * Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
613 ******************************************************************************/
616 acpi_ns_dump_objects(acpi_object_type type,
619 acpi_owner_id owner_id, acpi_handle start_handle)
621 struct acpi_walk_info info;
623 ACPI_FUNCTION_ENTRY();
625 info.debug_level = ACPI_LV_TABLES;
626 info.owner_id = owner_id;
627 info.display_type = display_type;
629 (void)acpi_ns_walk_namespace(type, start_handle, max_depth,
630 ACPI_NS_WALK_NO_UNLOCK |
631 ACPI_NS_WALK_TEMP_NODES,
632 acpi_ns_dump_one_object, (void *)&info,
635 #endif /* ACPI_FUTURE_USAGE */
637 /*******************************************************************************
639 * FUNCTION: acpi_ns_dump_entry
641 * PARAMETERS: Handle - Node to be dumped
642 * debug_level - Output level
646 * DESCRIPTION: Dump a single Node
648 ******************************************************************************/
650 void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level)
652 struct acpi_walk_info info;
654 ACPI_FUNCTION_ENTRY();
656 info.debug_level = debug_level;
657 info.owner_id = ACPI_OWNER_ID_MAX;
658 info.display_type = ACPI_DISPLAY_SUMMARY;
660 (void)acpi_ns_dump_one_object(handle, 1, &info, NULL);
663 #ifdef ACPI_ASL_COMPILER
664 /*******************************************************************************
666 * FUNCTION: acpi_ns_dump_tables
668 * PARAMETERS: search_base - Root of subtree to be dumped, or
669 * NS_ALL to dump the entire namespace
670 * max_depth - Maximum depth of dump. Use INT_MAX
671 * for an effectively unlimited depth.
675 * DESCRIPTION: Dump the name space, or a portion of it.
677 ******************************************************************************/
679 void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
681 acpi_handle search_handle = search_base;
683 ACPI_FUNCTION_TRACE(ns_dump_tables);
685 if (!acpi_gbl_root_node) {
687 * If the name space has not been initialized,
688 * there is nothing to dump.
690 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
691 "namespace not initialized!\n"));
695 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) */