ACPICA: Linuxize: Export debugger files to Linux
[linux-2.6/btrfs-unstable.git] / drivers / acpi / acpica / dbnames.c
blob04ff1ebfda5879f3207f29a1413509f567f46f57
1 /*******************************************************************************
3 * Module Name: dbnames - Debugger commands for the acpi namespace
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2015, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include "accommon.h"
46 #include "acnamesp.h"
47 #include "acdebug.h"
48 #include "acpredef.h"
50 #define _COMPONENT ACPI_CA_DEBUGGER
51 ACPI_MODULE_NAME("dbnames")
53 /* Local prototypes */
54 static acpi_status
55 acpi_db_walk_and_match_name(acpi_handle obj_handle,
56 u32 nesting_level,
57 void *context, void **return_value);
59 static acpi_status
60 acpi_db_walk_for_predefined_names(acpi_handle obj_handle,
61 u32 nesting_level,
62 void *context, void **return_value);
64 static acpi_status
65 acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
66 u32 nesting_level,
67 void *context, void **return_value);
69 static acpi_status
70 acpi_db_walk_for_object_counts(acpi_handle obj_handle,
71 u32 nesting_level,
72 void *context, void **return_value);
74 static acpi_status
75 acpi_db_integrity_walk(acpi_handle obj_handle,
76 u32 nesting_level, void *context, void **return_value);
78 static acpi_status
79 acpi_db_walk_for_references(acpi_handle obj_handle,
80 u32 nesting_level,
81 void *context, void **return_value);
83 static acpi_status
84 acpi_db_bus_walk(acpi_handle obj_handle,
85 u32 nesting_level, void *context, void **return_value);
88 * Arguments for the Objects command
89 * These object types map directly to the ACPI_TYPES
91 static struct acpi_db_argument_info acpi_db_object_types[] = {
92 {"ANY"},
93 {"INTEGERS"},
94 {"STRINGS"},
95 {"BUFFERS"},
96 {"PACKAGES"},
97 {"FIELDS"},
98 {"DEVICES"},
99 {"EVENTS"},
100 {"METHODS"},
101 {"MUTEXES"},
102 {"REGIONS"},
103 {"POWERRESOURCES"},
104 {"PROCESSORS"},
105 {"THERMALZONES"},
106 {"BUFFERFIELDS"},
107 {"DDBHANDLES"},
108 {"DEBUG"},
109 {"REGIONFIELDS"},
110 {"BANKFIELDS"},
111 {"INDEXFIELDS"},
112 {"REFERENCES"},
113 {"ALIASES"},
114 {"METHODALIASES"},
115 {"NOTIFY"},
116 {"ADDRESSHANDLER"},
117 {"RESOURCE"},
118 {"RESOURCEFIELD"},
119 {"SCOPES"},
120 {NULL} /* Must be null terminated */
123 /*******************************************************************************
125 * FUNCTION: acpi_db_set_scope
127 * PARAMETERS: name - New scope path
129 * RETURN: Status
131 * DESCRIPTION: Set the "current scope" as maintained by this utility.
132 * The scope is used as a prefix to ACPI paths.
134 ******************************************************************************/
136 void acpi_db_set_scope(char *name)
138 acpi_status status;
139 struct acpi_namespace_node *node;
141 if (!name || name[0] == 0) {
142 acpi_os_printf("Current scope: %s\n", acpi_gbl_db_scope_buf);
143 return;
146 acpi_db_prep_namestring(name);
148 if (ACPI_IS_ROOT_PREFIX(name[0])) {
150 /* Validate new scope from the root */
152 status = acpi_ns_get_node(acpi_gbl_root_node, name,
153 ACPI_NS_NO_UPSEARCH, &node);
154 if (ACPI_FAILURE(status)) {
155 goto error_exit;
158 acpi_gbl_db_scope_buf[0] = 0;
159 } else {
160 /* Validate new scope relative to old scope */
162 status = acpi_ns_get_node(acpi_gbl_db_scope_node, name,
163 ACPI_NS_NO_UPSEARCH, &node);
164 if (ACPI_FAILURE(status)) {
165 goto error_exit;
169 /* Build the final pathname */
171 if (acpi_ut_safe_strcat
172 (acpi_gbl_db_scope_buf, sizeof(acpi_gbl_db_scope_buf), name)) {
173 status = AE_BUFFER_OVERFLOW;
174 goto error_exit;
177 if (acpi_ut_safe_strcat
178 (acpi_gbl_db_scope_buf, sizeof(acpi_gbl_db_scope_buf), "\\")) {
179 status = AE_BUFFER_OVERFLOW;
180 goto error_exit;
183 acpi_gbl_db_scope_node = node;
184 acpi_os_printf("New scope: %s\n", acpi_gbl_db_scope_buf);
185 return;
187 error_exit:
189 acpi_os_printf("Could not attach scope: %s, %s\n",
190 name, acpi_format_exception(status));
193 /*******************************************************************************
195 * FUNCTION: acpi_db_dump_namespace
197 * PARAMETERS: start_arg - Node to begin namespace dump
198 * depth_arg - Maximum tree depth to be dumped
200 * RETURN: None
202 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
203 * with type and other information.
205 ******************************************************************************/
207 void acpi_db_dump_namespace(char *start_arg, char *depth_arg)
209 acpi_handle subtree_entry = acpi_gbl_root_node;
210 u32 max_depth = ACPI_UINT32_MAX;
212 /* No argument given, just start at the root and dump entire namespace */
214 if (start_arg) {
215 subtree_entry = acpi_db_convert_to_node(start_arg);
216 if (!subtree_entry) {
217 return;
220 /* Now we can check for the depth argument */
222 if (depth_arg) {
223 max_depth = strtoul(depth_arg, NULL, 0);
227 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
228 acpi_os_printf("ACPI Namespace (from %4.4s (%p) subtree):\n",
229 ((struct acpi_namespace_node *)subtree_entry)->name.
230 ascii, subtree_entry);
232 /* Display the subtree */
234 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
235 acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth,
236 ACPI_OWNER_ID_MAX, subtree_entry);
237 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
240 /*******************************************************************************
242 * FUNCTION: acpi_db_dump_namespace_paths
244 * PARAMETERS: None
246 * RETURN: None
248 * DESCRIPTION: Dump entire namespace with full object pathnames and object
249 * type information. Alternative to "namespace" command.
251 ******************************************************************************/
253 void acpi_db_dump_namespace_paths(void)
256 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
257 acpi_os_printf("ACPI Namespace (from root):\n");
259 /* Display the entire namespace */
261 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
262 acpi_ns_dump_object_paths(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY,
263 ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX,
264 acpi_gbl_root_node);
266 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
269 /*******************************************************************************
271 * FUNCTION: acpi_db_dump_namespace_by_owner
273 * PARAMETERS: owner_arg - Owner ID whose nodes will be displayed
274 * depth_arg - Maximum tree depth to be dumped
276 * RETURN: None
278 * DESCRIPTION: Dump elements of the namespace that are owned by the owner_id.
280 ******************************************************************************/
282 void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg)
284 acpi_handle subtree_entry = acpi_gbl_root_node;
285 u32 max_depth = ACPI_UINT32_MAX;
286 acpi_owner_id owner_id;
288 owner_id = (acpi_owner_id) strtoul(owner_arg, NULL, 0);
290 /* Now we can check for the depth argument */
292 if (depth_arg) {
293 max_depth = strtoul(depth_arg, NULL, 0);
296 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
297 acpi_os_printf("ACPI Namespace by owner %X:\n", owner_id);
299 /* Display the subtree */
301 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
302 acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth,
303 owner_id, subtree_entry);
304 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
307 /*******************************************************************************
309 * FUNCTION: acpi_db_walk_and_match_name
311 * PARAMETERS: Callback from walk_namespace
313 * RETURN: Status
315 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
316 * are supported -- '?' matches any character.
318 ******************************************************************************/
320 static acpi_status
321 acpi_db_walk_and_match_name(acpi_handle obj_handle,
322 u32 nesting_level,
323 void *context, void **return_value)
325 acpi_status status;
326 char *requested_name = (char *)context;
327 u32 i;
328 struct acpi_buffer buffer;
329 struct acpi_walk_info info;
331 /* Check for a name match */
333 for (i = 0; i < 4; i++) {
335 /* Wildcard support */
337 if ((requested_name[i] != '?') &&
338 (requested_name[i] != ((struct acpi_namespace_node *)
339 obj_handle)->name.ascii[i])) {
341 /* No match, just exit */
343 return (AE_OK);
347 /* Get the full pathname to this object */
349 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
350 status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
351 if (ACPI_FAILURE(status)) {
352 acpi_os_printf("Could Not get pathname for object %p\n",
353 obj_handle);
354 } else {
355 info.owner_id = ACPI_OWNER_ID_MAX;
356 info.debug_level = ACPI_UINT32_MAX;
357 info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
359 acpi_os_printf("%32s", (char *)buffer.pointer);
360 (void)acpi_ns_dump_one_object(obj_handle, nesting_level, &info,
361 NULL);
362 ACPI_FREE(buffer.pointer);
365 return (AE_OK);
368 /*******************************************************************************
370 * FUNCTION: acpi_db_find_name_in_namespace
372 * PARAMETERS: name_arg - The 4-character ACPI name to find.
373 * wildcards are supported.
375 * RETURN: None
377 * DESCRIPTION: Search the namespace for a given name (with wildcards)
379 ******************************************************************************/
381 acpi_status acpi_db_find_name_in_namespace(char *name_arg)
383 char acpi_name[5] = "____";
384 char *acpi_name_ptr = acpi_name;
386 if (strlen(name_arg) > ACPI_NAME_SIZE) {
387 acpi_os_printf("Name must be no longer than 4 characters\n");
388 return (AE_OK);
391 /* Pad out name with underscores as necessary to create a 4-char name */
393 acpi_ut_strupr(name_arg);
394 while (*name_arg) {
395 *acpi_name_ptr = *name_arg;
396 acpi_name_ptr++;
397 name_arg++;
400 /* Walk the namespace from the root */
402 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
403 ACPI_UINT32_MAX, acpi_db_walk_and_match_name,
404 NULL, acpi_name, NULL);
406 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
407 return (AE_OK);
410 /*******************************************************************************
412 * FUNCTION: acpi_db_walk_for_predefined_names
414 * PARAMETERS: Callback from walk_namespace
416 * RETURN: Status
418 * DESCRIPTION: Detect and display predefined ACPI names (names that start with
419 * an underscore)
421 ******************************************************************************/
423 static acpi_status
424 acpi_db_walk_for_predefined_names(acpi_handle obj_handle,
425 u32 nesting_level,
426 void *context, void **return_value)
428 struct acpi_namespace_node *node =
429 (struct acpi_namespace_node *)obj_handle;
430 u32 *count = (u32 *)context;
431 const union acpi_predefined_info *predefined;
432 const union acpi_predefined_info *package = NULL;
433 char *pathname;
434 char string_buffer[48];
436 predefined = acpi_ut_match_predefined_method(node->name.ascii);
437 if (!predefined) {
438 return (AE_OK);
441 pathname = acpi_ns_get_external_pathname(node);
442 if (!pathname) {
443 return (AE_OK);
446 /* If method returns a package, the info is in the next table entry */
448 if (predefined->info.expected_btypes & ACPI_RTYPE_PACKAGE) {
449 package = predefined + 1;
452 acpi_ut_get_expected_return_types(string_buffer,
453 predefined->info.expected_btypes);
455 acpi_os_printf("%-32s Arguments %X, Return Types: %s", pathname,
456 METHOD_GET_ARG_COUNT(predefined->info.argument_list),
457 string_buffer);
459 if (package) {
460 acpi_os_printf(" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)",
461 package->ret_info.type,
462 package->ret_info.object_type1,
463 package->ret_info.count1);
466 acpi_os_printf("\n");
468 /* Check that the declared argument count matches the ACPI spec */
470 acpi_ns_check_acpi_compliance(pathname, node, predefined);
472 ACPI_FREE(pathname);
473 (*count)++;
474 return (AE_OK);
477 /*******************************************************************************
479 * FUNCTION: acpi_db_check_predefined_names
481 * PARAMETERS: None
483 * RETURN: None
485 * DESCRIPTION: Validate all predefined names in the namespace
487 ******************************************************************************/
489 void acpi_db_check_predefined_names(void)
491 u32 count = 0;
493 /* Search all nodes in namespace */
495 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
496 ACPI_UINT32_MAX,
497 acpi_db_walk_for_predefined_names, NULL,
498 (void *)&count, NULL);
500 acpi_os_printf("Found %u predefined names in the namespace\n", count);
503 /*******************************************************************************
505 * FUNCTION: acpi_db_walk_for_object_counts
507 * PARAMETERS: Callback from walk_namespace
509 * RETURN: Status
511 * DESCRIPTION: Display short info about objects in the namespace
513 ******************************************************************************/
515 static acpi_status
516 acpi_db_walk_for_object_counts(acpi_handle obj_handle,
517 u32 nesting_level,
518 void *context, void **return_value)
520 struct acpi_object_info *info = (struct acpi_object_info *)context;
521 struct acpi_namespace_node *node =
522 (struct acpi_namespace_node *)obj_handle;
524 if (node->type > ACPI_TYPE_NS_NODE_MAX) {
525 acpi_os_printf("[%4.4s]: Unknown object type %X\n",
526 node->name.ascii, node->type);
527 } else {
528 info->types[node->type]++;
531 return (AE_OK);
534 /*******************************************************************************
536 * FUNCTION: acpi_db_walk_for_specific_objects
538 * PARAMETERS: Callback from walk_namespace
540 * RETURN: Status
542 * DESCRIPTION: Display short info about objects in the namespace
544 ******************************************************************************/
546 static acpi_status
547 acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
548 u32 nesting_level,
549 void *context, void **return_value)
551 struct acpi_walk_info *info = (struct acpi_walk_info *)context;
552 struct acpi_buffer buffer;
553 acpi_status status;
555 info->count++;
557 /* Get and display the full pathname to this object */
559 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
560 status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
561 if (ACPI_FAILURE(status)) {
562 acpi_os_printf("Could Not get pathname for object %p\n",
563 obj_handle);
564 return (AE_OK);
567 acpi_os_printf("%32s", (char *)buffer.pointer);
568 ACPI_FREE(buffer.pointer);
570 /* Dump short info about the object */
572 (void)acpi_ns_dump_one_object(obj_handle, nesting_level, info, NULL);
573 return (AE_OK);
576 /*******************************************************************************
578 * FUNCTION: acpi_db_display_objects
580 * PARAMETERS: obj_type_arg - Type of object to display
581 * display_count_arg - Max depth to display
583 * RETURN: None
585 * DESCRIPTION: Display objects in the namespace of the requested type
587 ******************************************************************************/
589 acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
591 struct acpi_walk_info info;
592 acpi_object_type type;
593 struct acpi_object_info *object_info;
594 u32 i;
595 u32 total_objects = 0;
597 /* No argument means display summary/count of all object types */
599 if (!obj_type_arg) {
600 object_info =
601 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));
603 /* Walk the namespace from the root */
605 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
606 ACPI_UINT32_MAX,
607 acpi_db_walk_for_object_counts, NULL,
608 (void *)object_info, NULL);
610 acpi_os_printf("\nSummary of namespace objects:\n\n");
612 for (i = 0; i < ACPI_TOTAL_TYPES; i++) {
613 acpi_os_printf("%8u %s\n", object_info->types[i],
614 acpi_ut_get_type_name(i));
616 total_objects += object_info->types[i];
619 acpi_os_printf("\n%8u Total namespace objects\n\n",
620 total_objects);
622 ACPI_FREE(object_info);
623 return (AE_OK);
626 /* Get the object type */
628 type = acpi_db_match_argument(obj_type_arg, acpi_db_object_types);
629 if (type == ACPI_TYPE_NOT_FOUND) {
630 acpi_os_printf("Invalid or unsupported argument\n");
631 return (AE_OK);
634 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
635 acpi_os_printf
636 ("Objects of type [%s] defined in the current ACPI Namespace:\n",
637 acpi_ut_get_type_name(type));
639 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
641 info.count = 0;
642 info.owner_id = ACPI_OWNER_ID_MAX;
643 info.debug_level = ACPI_UINT32_MAX;
644 info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
646 /* Walk the namespace from the root */
648 (void)acpi_walk_namespace(type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
649 acpi_db_walk_for_specific_objects, NULL,
650 (void *)&info, NULL);
652 acpi_os_printf
653 ("\nFound %u objects of type [%s] in the current ACPI Namespace\n",
654 info.count, acpi_ut_get_type_name(type));
656 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
657 return (AE_OK);
660 /*******************************************************************************
662 * FUNCTION: acpi_db_integrity_walk
664 * PARAMETERS: Callback from walk_namespace
666 * RETURN: Status
668 * DESCRIPTION: Examine one NS node for valid values.
670 ******************************************************************************/
672 static acpi_status
673 acpi_db_integrity_walk(acpi_handle obj_handle,
674 u32 nesting_level, void *context, void **return_value)
676 struct acpi_integrity_info *info =
677 (struct acpi_integrity_info *)context;
678 struct acpi_namespace_node *node =
679 (struct acpi_namespace_node *)obj_handle;
680 union acpi_operand_object *object;
681 u8 alias = TRUE;
683 info->nodes++;
685 /* Verify the NS node, and dereference aliases */
687 while (alias) {
688 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
689 acpi_os_printf
690 ("Invalid Descriptor Type for Node %p [%s] - "
691 "is %2.2X should be %2.2X\n", node,
692 acpi_ut_get_descriptor_name(node),
693 ACPI_GET_DESCRIPTOR_TYPE(node),
694 ACPI_DESC_TYPE_NAMED);
695 return (AE_OK);
698 if ((node->type == ACPI_TYPE_LOCAL_ALIAS) ||
699 (node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
700 node = (struct acpi_namespace_node *)node->object;
701 } else {
702 alias = FALSE;
706 if (node->type > ACPI_TYPE_LOCAL_MAX) {
707 acpi_os_printf("Invalid Object Type for Node %p, Type = %X\n",
708 node, node->type);
709 return (AE_OK);
712 if (!acpi_ut_valid_acpi_name(node->name.ascii)) {
713 acpi_os_printf("Invalid AcpiName for Node %p\n", node);
714 return (AE_OK);
717 object = acpi_ns_get_attached_object(node);
718 if (object) {
719 info->objects++;
720 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
721 acpi_os_printf
722 ("Invalid Descriptor Type for Object %p [%s]\n",
723 object, acpi_ut_get_descriptor_name(object));
727 return (AE_OK);
730 /*******************************************************************************
732 * FUNCTION: acpi_db_check_integrity
734 * PARAMETERS: None
736 * RETURN: None
738 * DESCRIPTION: Check entire namespace for data structure integrity
740 ******************************************************************************/
742 void acpi_db_check_integrity(void)
744 struct acpi_integrity_info info = { 0, 0 };
746 /* Search all nodes in namespace */
748 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
749 ACPI_UINT32_MAX, acpi_db_integrity_walk, NULL,
750 (void *)&info, NULL);
752 acpi_os_printf("Verified %u namespace nodes with %u Objects\n",
753 info.nodes, info.objects);
756 /*******************************************************************************
758 * FUNCTION: acpi_db_walk_for_references
760 * PARAMETERS: Callback from walk_namespace
762 * RETURN: Status
764 * DESCRIPTION: Check if this namespace object refers to the target object
765 * that is passed in as the context value.
767 * Note: Currently doesn't check subobjects within the Node's object
769 ******************************************************************************/
771 static acpi_status
772 acpi_db_walk_for_references(acpi_handle obj_handle,
773 u32 nesting_level,
774 void *context, void **return_value)
776 union acpi_operand_object *obj_desc =
777 (union acpi_operand_object *)context;
778 struct acpi_namespace_node *node =
779 (struct acpi_namespace_node *)obj_handle;
781 /* Check for match against the namespace node itself */
783 if (node == (void *)obj_desc) {
784 acpi_os_printf("Object is a Node [%4.4s]\n",
785 acpi_ut_get_node_name(node));
788 /* Check for match against the object attached to the node */
790 if (acpi_ns_get_attached_object(node) == obj_desc) {
791 acpi_os_printf("Reference at Node->Object %p [%4.4s]\n",
792 node, acpi_ut_get_node_name(node));
795 return (AE_OK);
798 /*******************************************************************************
800 * FUNCTION: acpi_db_find_references
802 * PARAMETERS: object_arg - String with hex value of the object
804 * RETURN: None
806 * DESCRIPTION: Search namespace for all references to the input object
808 ******************************************************************************/
810 void acpi_db_find_references(char *object_arg)
812 union acpi_operand_object *obj_desc;
813 acpi_size address;
815 /* Convert string to object pointer */
817 address = strtoul(object_arg, NULL, 16);
818 obj_desc = ACPI_TO_POINTER(address);
820 /* Search all nodes in namespace */
822 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
823 ACPI_UINT32_MAX, acpi_db_walk_for_references,
824 NULL, (void *)obj_desc, NULL);
827 /*******************************************************************************
829 * FUNCTION: acpi_db_bus_walk
831 * PARAMETERS: Callback from walk_namespace
833 * RETURN: Status
835 * DESCRIPTION: Display info about device objects that have a corresponding
836 * _PRT method.
838 ******************************************************************************/
840 static acpi_status
841 acpi_db_bus_walk(acpi_handle obj_handle,
842 u32 nesting_level, void *context, void **return_value)
844 struct acpi_namespace_node *node =
845 (struct acpi_namespace_node *)obj_handle;
846 acpi_status status;
847 struct acpi_buffer buffer;
848 struct acpi_namespace_node *temp_node;
849 struct acpi_device_info *info;
850 u32 i;
852 if ((node->type != ACPI_TYPE_DEVICE) &&
853 (node->type != ACPI_TYPE_PROCESSOR)) {
854 return (AE_OK);
857 /* Exit if there is no _PRT under this device */
859 status = acpi_get_handle(node, METHOD_NAME__PRT,
860 ACPI_CAST_PTR(acpi_handle, &temp_node));
861 if (ACPI_FAILURE(status)) {
862 return (AE_OK);
865 /* Get the full path to this device object */
867 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
868 status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
869 if (ACPI_FAILURE(status)) {
870 acpi_os_printf("Could Not get pathname for object %p\n",
871 obj_handle);
872 return (AE_OK);
875 status = acpi_get_object_info(obj_handle, &info);
876 if (ACPI_FAILURE(status)) {
877 return (AE_OK);
880 /* Display the full path */
882 acpi_os_printf("%-32s Type %X", (char *)buffer.pointer, node->type);
883 ACPI_FREE(buffer.pointer);
885 if (info->flags & ACPI_PCI_ROOT_BRIDGE) {
886 acpi_os_printf(" - Is PCI Root Bridge");
888 acpi_os_printf("\n");
890 /* _PRT info */
892 acpi_os_printf("_PRT: %p\n", temp_node);
894 /* Dump _ADR, _HID, _UID, _CID */
896 if (info->valid & ACPI_VALID_ADR) {
897 acpi_os_printf("_ADR: %8.8X%8.8X\n",
898 ACPI_FORMAT_UINT64(info->address));
899 } else {
900 acpi_os_printf("_ADR: <Not Present>\n");
903 if (info->valid & ACPI_VALID_HID) {
904 acpi_os_printf("_HID: %s\n", info->hardware_id.string);
905 } else {
906 acpi_os_printf("_HID: <Not Present>\n");
909 if (info->valid & ACPI_VALID_UID) {
910 acpi_os_printf("_UID: %s\n", info->unique_id.string);
911 } else {
912 acpi_os_printf("_UID: <Not Present>\n");
915 if (info->valid & ACPI_VALID_CID) {
916 for (i = 0; i < info->compatible_id_list.count; i++) {
917 acpi_os_printf("_CID: %s\n",
918 info->compatible_id_list.ids[i].string);
920 } else {
921 acpi_os_printf("_CID: <Not Present>\n");
924 ACPI_FREE(info);
925 return (AE_OK);
928 /*******************************************************************************
930 * FUNCTION: acpi_db_get_bus_info
932 * PARAMETERS: None
934 * RETURN: None
936 * DESCRIPTION: Display info about system busses.
938 ******************************************************************************/
940 void acpi_db_get_bus_info(void)
942 /* Search all nodes in namespace */
944 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
945 ACPI_UINT32_MAX, acpi_db_bus_walk, NULL, NULL,
946 NULL);