Linux 4.19.133
[linux/fpc-iii.git] / drivers / acpi / acpica / dbnames.c
blob992bd7b92540d6afff1083164e0f0e237a2f2a08
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /*******************************************************************************
4 * Module Name: dbnames - Debugger commands for the acpi namespace
6 ******************************************************************************/
8 #include <acpi/acpi.h>
9 #include "accommon.h"
10 #include "acnamesp.h"
11 #include "acdebug.h"
12 #include "acpredef.h"
14 #define _COMPONENT ACPI_CA_DEBUGGER
15 ACPI_MODULE_NAME("dbnames")
17 /* Local prototypes */
18 static acpi_status
19 acpi_db_walk_and_match_name(acpi_handle obj_handle,
20 u32 nesting_level,
21 void *context, void **return_value);
23 static acpi_status
24 acpi_db_walk_for_predefined_names(acpi_handle obj_handle,
25 u32 nesting_level,
26 void *context, void **return_value);
28 static acpi_status
29 acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
30 u32 nesting_level,
31 void *context, void **return_value);
33 static acpi_status
34 acpi_db_walk_for_object_counts(acpi_handle obj_handle,
35 u32 nesting_level,
36 void *context, void **return_value);
38 static acpi_status
39 acpi_db_integrity_walk(acpi_handle obj_handle,
40 u32 nesting_level, void *context, void **return_value);
42 static acpi_status
43 acpi_db_walk_for_references(acpi_handle obj_handle,
44 u32 nesting_level,
45 void *context, void **return_value);
47 static acpi_status
48 acpi_db_bus_walk(acpi_handle obj_handle,
49 u32 nesting_level, void *context, void **return_value);
52 * Arguments for the Objects command
53 * These object types map directly to the ACPI_TYPES
55 static struct acpi_db_argument_info acpi_db_object_types[] = {
56 {"ANY"},
57 {"INTEGERS"},
58 {"STRINGS"},
59 {"BUFFERS"},
60 {"PACKAGES"},
61 {"FIELDS"},
62 {"DEVICES"},
63 {"EVENTS"},
64 {"METHODS"},
65 {"MUTEXES"},
66 {"REGIONS"},
67 {"POWERRESOURCES"},
68 {"PROCESSORS"},
69 {"THERMALZONES"},
70 {"BUFFERFIELDS"},
71 {"DDBHANDLES"},
72 {"DEBUG"},
73 {"REGIONFIELDS"},
74 {"BANKFIELDS"},
75 {"INDEXFIELDS"},
76 {"REFERENCES"},
77 {"ALIASES"},
78 {"METHODALIASES"},
79 {"NOTIFY"},
80 {"ADDRESSHANDLER"},
81 {"RESOURCE"},
82 {"RESOURCEFIELD"},
83 {"SCOPES"},
84 {NULL} /* Must be null terminated */
87 /*******************************************************************************
89 * FUNCTION: acpi_db_set_scope
91 * PARAMETERS: name - New scope path
93 * RETURN: Status
95 * DESCRIPTION: Set the "current scope" as maintained by this utility.
96 * The scope is used as a prefix to ACPI paths.
98 ******************************************************************************/
100 void acpi_db_set_scope(char *name)
102 acpi_status status;
103 struct acpi_namespace_node *node;
105 if (!name || name[0] == 0) {
106 acpi_os_printf("Current scope: %s\n", acpi_gbl_db_scope_buf);
107 return;
110 acpi_db_prep_namestring(name);
112 if (ACPI_IS_ROOT_PREFIX(name[0])) {
114 /* Validate new scope from the root */
116 status = acpi_ns_get_node(acpi_gbl_root_node, name,
117 ACPI_NS_NO_UPSEARCH, &node);
118 if (ACPI_FAILURE(status)) {
119 goto error_exit;
122 acpi_gbl_db_scope_buf[0] = 0;
123 } else {
124 /* Validate new scope relative to old scope */
126 status = acpi_ns_get_node(acpi_gbl_db_scope_node, name,
127 ACPI_NS_NO_UPSEARCH, &node);
128 if (ACPI_FAILURE(status)) {
129 goto error_exit;
133 /* Build the final pathname */
135 if (acpi_ut_safe_strcat
136 (acpi_gbl_db_scope_buf, sizeof(acpi_gbl_db_scope_buf), name)) {
137 status = AE_BUFFER_OVERFLOW;
138 goto error_exit;
141 if (acpi_ut_safe_strcat
142 (acpi_gbl_db_scope_buf, sizeof(acpi_gbl_db_scope_buf), "\\")) {
143 status = AE_BUFFER_OVERFLOW;
144 goto error_exit;
147 acpi_gbl_db_scope_node = node;
148 acpi_os_printf("New scope: %s\n", acpi_gbl_db_scope_buf);
149 return;
151 error_exit:
153 acpi_os_printf("Could not attach scope: %s, %s\n",
154 name, acpi_format_exception(status));
157 /*******************************************************************************
159 * FUNCTION: acpi_db_dump_namespace
161 * PARAMETERS: start_arg - Node to begin namespace dump
162 * depth_arg - Maximum tree depth to be dumped
164 * RETURN: None
166 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
167 * with type and other information.
169 ******************************************************************************/
171 void acpi_db_dump_namespace(char *start_arg, char *depth_arg)
173 acpi_handle subtree_entry = acpi_gbl_root_node;
174 u32 max_depth = ACPI_UINT32_MAX;
176 /* No argument given, just start at the root and dump entire namespace */
178 if (start_arg) {
179 subtree_entry = acpi_db_convert_to_node(start_arg);
180 if (!subtree_entry) {
181 return;
184 /* Now we can check for the depth argument */
186 if (depth_arg) {
187 max_depth = strtoul(depth_arg, NULL, 0);
191 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
193 if (((struct acpi_namespace_node *)subtree_entry)->parent) {
194 acpi_os_printf("ACPI Namespace (from %4.4s (%p) subtree):\n",
195 ((struct acpi_namespace_node *)subtree_entry)->
196 name.ascii, subtree_entry);
197 } else {
198 acpi_os_printf("ACPI Namespace (from %s):\n",
199 ACPI_NAMESPACE_ROOT);
202 /* Display the subtree */
204 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
205 acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth,
206 ACPI_OWNER_ID_MAX, subtree_entry);
207 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
210 /*******************************************************************************
212 * FUNCTION: acpi_db_dump_namespace_paths
214 * PARAMETERS: None
216 * RETURN: None
218 * DESCRIPTION: Dump entire namespace with full object pathnames and object
219 * type information. Alternative to "namespace" command.
221 ******************************************************************************/
223 void acpi_db_dump_namespace_paths(void)
226 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
227 acpi_os_printf("ACPI Namespace (from root):\n");
229 /* Display the entire namespace */
231 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
232 acpi_ns_dump_object_paths(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY,
233 ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX,
234 acpi_gbl_root_node);
236 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
239 /*******************************************************************************
241 * FUNCTION: acpi_db_dump_namespace_by_owner
243 * PARAMETERS: owner_arg - Owner ID whose nodes will be displayed
244 * depth_arg - Maximum tree depth to be dumped
246 * RETURN: None
248 * DESCRIPTION: Dump elements of the namespace that are owned by the owner_id.
250 ******************************************************************************/
252 void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg)
254 acpi_handle subtree_entry = acpi_gbl_root_node;
255 u32 max_depth = ACPI_UINT32_MAX;
256 acpi_owner_id owner_id;
258 owner_id = (acpi_owner_id)strtoul(owner_arg, NULL, 0);
260 /* Now we can check for the depth argument */
262 if (depth_arg) {
263 max_depth = strtoul(depth_arg, NULL, 0);
266 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
267 acpi_os_printf("ACPI Namespace by owner %X:\n", owner_id);
269 /* Display the subtree */
271 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
272 acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth,
273 owner_id, subtree_entry);
274 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
277 /*******************************************************************************
279 * FUNCTION: acpi_db_walk_and_match_name
281 * PARAMETERS: Callback from walk_namespace
283 * RETURN: Status
285 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
286 * are supported -- '?' matches any character.
288 ******************************************************************************/
290 static acpi_status
291 acpi_db_walk_and_match_name(acpi_handle obj_handle,
292 u32 nesting_level,
293 void *context, void **return_value)
295 acpi_status status;
296 char *requested_name = (char *)context;
297 u32 i;
298 struct acpi_buffer buffer;
299 struct acpi_walk_info info;
301 /* Check for a name match */
303 for (i = 0; i < 4; i++) {
305 /* Wildcard support */
307 if ((requested_name[i] != '?') &&
308 (requested_name[i] != ((struct acpi_namespace_node *)
309 obj_handle)->name.ascii[i])) {
311 /* No match, just exit */
313 return (AE_OK);
317 /* Get the full pathname to this object */
319 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
320 status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
321 if (ACPI_FAILURE(status)) {
322 acpi_os_printf("Could Not get pathname for object %p\n",
323 obj_handle);
324 } else {
325 info.count = 0;
326 info.owner_id = ACPI_OWNER_ID_MAX;
327 info.debug_level = ACPI_UINT32_MAX;
328 info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
330 acpi_os_printf("%32s", (char *)buffer.pointer);
331 (void)acpi_ns_dump_one_object(obj_handle, nesting_level, &info,
332 NULL);
333 ACPI_FREE(buffer.pointer);
336 return (AE_OK);
339 /*******************************************************************************
341 * FUNCTION: acpi_db_find_name_in_namespace
343 * PARAMETERS: name_arg - The 4-character ACPI name to find.
344 * wildcards are supported.
346 * RETURN: None
348 * DESCRIPTION: Search the namespace for a given name (with wildcards)
350 ******************************************************************************/
352 acpi_status acpi_db_find_name_in_namespace(char *name_arg)
354 char acpi_name[5] = "____";
355 char *acpi_name_ptr = acpi_name;
357 if (strlen(name_arg) > ACPI_NAME_SIZE) {
358 acpi_os_printf("Name must be no longer than 4 characters\n");
359 return (AE_OK);
362 /* Pad out name with underscores as necessary to create a 4-char name */
364 acpi_ut_strupr(name_arg);
365 while (*name_arg) {
366 *acpi_name_ptr = *name_arg;
367 acpi_name_ptr++;
368 name_arg++;
371 /* Walk the namespace from the root */
373 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
374 ACPI_UINT32_MAX, acpi_db_walk_and_match_name,
375 NULL, acpi_name, NULL);
377 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
378 return (AE_OK);
381 /*******************************************************************************
383 * FUNCTION: acpi_db_walk_for_predefined_names
385 * PARAMETERS: Callback from walk_namespace
387 * RETURN: Status
389 * DESCRIPTION: Detect and display predefined ACPI names (names that start with
390 * an underscore)
392 ******************************************************************************/
394 static acpi_status
395 acpi_db_walk_for_predefined_names(acpi_handle obj_handle,
396 u32 nesting_level,
397 void *context, void **return_value)
399 struct acpi_namespace_node *node =
400 (struct acpi_namespace_node *)obj_handle;
401 u32 *count = (u32 *)context;
402 const union acpi_predefined_info *predefined;
403 const union acpi_predefined_info *package = NULL;
404 char *pathname;
405 char string_buffer[48];
407 predefined = acpi_ut_match_predefined_method(node->name.ascii);
408 if (!predefined) {
409 return (AE_OK);
412 pathname = acpi_ns_get_normalized_pathname(node, TRUE);
413 if (!pathname) {
414 return (AE_OK);
417 /* If method returns a package, the info is in the next table entry */
419 if (predefined->info.expected_btypes & ACPI_RTYPE_PACKAGE) {
420 package = predefined + 1;
423 acpi_ut_get_expected_return_types(string_buffer,
424 predefined->info.expected_btypes);
426 acpi_os_printf("%-32s Arguments %X, Return Types: %s", pathname,
427 METHOD_GET_ARG_COUNT(predefined->info.argument_list),
428 string_buffer);
430 if (package) {
431 acpi_os_printf(" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)",
432 package->ret_info.type,
433 package->ret_info.object_type1,
434 package->ret_info.count1);
437 acpi_os_printf("\n");
439 /* Check that the declared argument count matches the ACPI spec */
441 acpi_ns_check_acpi_compliance(pathname, node, predefined);
443 ACPI_FREE(pathname);
444 (*count)++;
445 return (AE_OK);
448 /*******************************************************************************
450 * FUNCTION: acpi_db_check_predefined_names
452 * PARAMETERS: None
454 * RETURN: None
456 * DESCRIPTION: Validate all predefined names in the namespace
458 ******************************************************************************/
460 void acpi_db_check_predefined_names(void)
462 u32 count = 0;
464 /* Search all nodes in namespace */
466 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
467 ACPI_UINT32_MAX,
468 acpi_db_walk_for_predefined_names, NULL,
469 (void *)&count, NULL);
471 acpi_os_printf("Found %u predefined names in the namespace\n", count);
474 /*******************************************************************************
476 * FUNCTION: acpi_db_walk_for_object_counts
478 * PARAMETERS: Callback from walk_namespace
480 * RETURN: Status
482 * DESCRIPTION: Display short info about objects in the namespace
484 ******************************************************************************/
486 static acpi_status
487 acpi_db_walk_for_object_counts(acpi_handle obj_handle,
488 u32 nesting_level,
489 void *context, void **return_value)
491 struct acpi_object_info *info = (struct acpi_object_info *)context;
492 struct acpi_namespace_node *node =
493 (struct acpi_namespace_node *)obj_handle;
495 if (node->type > ACPI_TYPE_NS_NODE_MAX) {
496 acpi_os_printf("[%4.4s]: Unknown object type %X\n",
497 node->name.ascii, node->type);
498 } else {
499 info->types[node->type]++;
502 return (AE_OK);
505 /*******************************************************************************
507 * FUNCTION: acpi_db_walk_for_specific_objects
509 * PARAMETERS: Callback from walk_namespace
511 * RETURN: Status
513 * DESCRIPTION: Display short info about objects in the namespace
515 ******************************************************************************/
517 static acpi_status
518 acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
519 u32 nesting_level,
520 void *context, void **return_value)
522 struct acpi_walk_info *info = (struct acpi_walk_info *)context;
523 struct acpi_buffer buffer;
524 acpi_status status;
526 info->count++;
528 /* Get and display the full pathname to this object */
530 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
531 status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
532 if (ACPI_FAILURE(status)) {
533 acpi_os_printf("Could Not get pathname for object %p\n",
534 obj_handle);
535 return (AE_OK);
538 acpi_os_printf("%32s", (char *)buffer.pointer);
539 ACPI_FREE(buffer.pointer);
541 /* Dump short info about the object */
543 (void)acpi_ns_dump_one_object(obj_handle, nesting_level, info, NULL);
544 return (AE_OK);
547 /*******************************************************************************
549 * FUNCTION: acpi_db_display_objects
551 * PARAMETERS: obj_type_arg - Type of object to display
552 * display_count_arg - Max depth to display
554 * RETURN: None
556 * DESCRIPTION: Display objects in the namespace of the requested type
558 ******************************************************************************/
560 acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
562 struct acpi_walk_info info;
563 acpi_object_type type;
564 struct acpi_object_info *object_info;
565 u32 i;
566 u32 total_objects = 0;
568 /* No argument means display summary/count of all object types */
570 if (!obj_type_arg) {
571 object_info =
572 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));
574 /* Walk the namespace from the root */
576 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
577 ACPI_UINT32_MAX,
578 acpi_db_walk_for_object_counts, NULL,
579 (void *)object_info, NULL);
581 acpi_os_printf("\nSummary of namespace objects:\n\n");
583 for (i = 0; i < ACPI_TOTAL_TYPES; i++) {
584 acpi_os_printf("%8u %s\n", object_info->types[i],
585 acpi_ut_get_type_name(i));
587 total_objects += object_info->types[i];
590 acpi_os_printf("\n%8u Total namespace objects\n\n",
591 total_objects);
593 ACPI_FREE(object_info);
594 return (AE_OK);
597 /* Get the object type */
599 type = acpi_db_match_argument(obj_type_arg, acpi_db_object_types);
600 if (type == ACPI_TYPE_NOT_FOUND) {
601 acpi_os_printf("Invalid or unsupported argument\n");
602 return (AE_OK);
605 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
606 acpi_os_printf
607 ("Objects of type [%s] defined in the current ACPI Namespace:\n",
608 acpi_ut_get_type_name(type));
610 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
612 info.count = 0;
613 info.owner_id = ACPI_OWNER_ID_MAX;
614 info.debug_level = ACPI_UINT32_MAX;
615 info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
617 /* Walk the namespace from the root */
619 (void)acpi_walk_namespace(type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
620 acpi_db_walk_for_specific_objects, NULL,
621 (void *)&info, NULL);
623 acpi_os_printf
624 ("\nFound %u objects of type [%s] in the current ACPI Namespace\n",
625 info.count, acpi_ut_get_type_name(type));
627 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
628 return (AE_OK);
631 /*******************************************************************************
633 * FUNCTION: acpi_db_integrity_walk
635 * PARAMETERS: Callback from walk_namespace
637 * RETURN: Status
639 * DESCRIPTION: Examine one NS node for valid values.
641 ******************************************************************************/
643 static acpi_status
644 acpi_db_integrity_walk(acpi_handle obj_handle,
645 u32 nesting_level, void *context, void **return_value)
647 struct acpi_integrity_info *info =
648 (struct acpi_integrity_info *)context;
649 struct acpi_namespace_node *node =
650 (struct acpi_namespace_node *)obj_handle;
651 union acpi_operand_object *object;
652 u8 alias = TRUE;
654 info->nodes++;
656 /* Verify the NS node, and dereference aliases */
658 while (alias) {
659 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
660 acpi_os_printf
661 ("Invalid Descriptor Type for Node %p [%s] - "
662 "is %2.2X should be %2.2X\n", node,
663 acpi_ut_get_descriptor_name(node),
664 ACPI_GET_DESCRIPTOR_TYPE(node),
665 ACPI_DESC_TYPE_NAMED);
666 return (AE_OK);
669 if ((node->type == ACPI_TYPE_LOCAL_ALIAS) ||
670 (node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
671 node = (struct acpi_namespace_node *)node->object;
672 } else {
673 alias = FALSE;
677 if (node->type > ACPI_TYPE_LOCAL_MAX) {
678 acpi_os_printf("Invalid Object Type for Node %p, Type = %X\n",
679 node, node->type);
680 return (AE_OK);
683 if (!acpi_ut_valid_nameseg(node->name.ascii)) {
684 acpi_os_printf("Invalid AcpiName for Node %p\n", node);
685 return (AE_OK);
688 object = acpi_ns_get_attached_object(node);
689 if (object) {
690 info->objects++;
691 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
692 acpi_os_printf
693 ("Invalid Descriptor Type for Object %p [%s]\n",
694 object, acpi_ut_get_descriptor_name(object));
698 return (AE_OK);
701 /*******************************************************************************
703 * FUNCTION: acpi_db_check_integrity
705 * PARAMETERS: None
707 * RETURN: None
709 * DESCRIPTION: Check entire namespace for data structure integrity
711 ******************************************************************************/
713 void acpi_db_check_integrity(void)
715 struct acpi_integrity_info info = { 0, 0 };
717 /* Search all nodes in namespace */
719 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
720 ACPI_UINT32_MAX, acpi_db_integrity_walk, NULL,
721 (void *)&info, NULL);
723 acpi_os_printf("Verified %u namespace nodes with %u Objects\n",
724 info.nodes, info.objects);
727 /*******************************************************************************
729 * FUNCTION: acpi_db_walk_for_references
731 * PARAMETERS: Callback from walk_namespace
733 * RETURN: Status
735 * DESCRIPTION: Check if this namespace object refers to the target object
736 * that is passed in as the context value.
738 * Note: Currently doesn't check subobjects within the Node's object
740 ******************************************************************************/
742 static acpi_status
743 acpi_db_walk_for_references(acpi_handle obj_handle,
744 u32 nesting_level,
745 void *context, void **return_value)
747 union acpi_operand_object *obj_desc =
748 (union acpi_operand_object *)context;
749 struct acpi_namespace_node *node =
750 (struct acpi_namespace_node *)obj_handle;
752 /* Check for match against the namespace node itself */
754 if (node == (void *)obj_desc) {
755 acpi_os_printf("Object is a Node [%4.4s]\n",
756 acpi_ut_get_node_name(node));
759 /* Check for match against the object attached to the node */
761 if (acpi_ns_get_attached_object(node) == obj_desc) {
762 acpi_os_printf("Reference at Node->Object %p [%4.4s]\n",
763 node, acpi_ut_get_node_name(node));
766 return (AE_OK);
769 /*******************************************************************************
771 * FUNCTION: acpi_db_find_references
773 * PARAMETERS: object_arg - String with hex value of the object
775 * RETURN: None
777 * DESCRIPTION: Search namespace for all references to the input object
779 ******************************************************************************/
781 void acpi_db_find_references(char *object_arg)
783 union acpi_operand_object *obj_desc;
784 acpi_size address;
786 /* Convert string to object pointer */
788 address = strtoul(object_arg, NULL, 16);
789 obj_desc = ACPI_TO_POINTER(address);
791 /* Search all nodes in namespace */
793 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
794 ACPI_UINT32_MAX, acpi_db_walk_for_references,
795 NULL, (void *)obj_desc, NULL);
798 /*******************************************************************************
800 * FUNCTION: acpi_db_bus_walk
802 * PARAMETERS: Callback from walk_namespace
804 * RETURN: Status
806 * DESCRIPTION: Display info about device objects that have a corresponding
807 * _PRT method.
809 ******************************************************************************/
811 static acpi_status
812 acpi_db_bus_walk(acpi_handle obj_handle,
813 u32 nesting_level, void *context, void **return_value)
815 struct acpi_namespace_node *node =
816 (struct acpi_namespace_node *)obj_handle;
817 acpi_status status;
818 struct acpi_buffer buffer;
819 struct acpi_namespace_node *temp_node;
820 struct acpi_device_info *info;
821 u32 i;
823 if ((node->type != ACPI_TYPE_DEVICE) &&
824 (node->type != ACPI_TYPE_PROCESSOR)) {
825 return (AE_OK);
828 /* Exit if there is no _PRT under this device */
830 status = acpi_get_handle(node, METHOD_NAME__PRT,
831 ACPI_CAST_PTR(acpi_handle, &temp_node));
832 if (ACPI_FAILURE(status)) {
833 return (AE_OK);
836 /* Get the full path to this device object */
838 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
839 status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
840 if (ACPI_FAILURE(status)) {
841 acpi_os_printf("Could Not get pathname for object %p\n",
842 obj_handle);
843 return (AE_OK);
846 status = acpi_get_object_info(obj_handle, &info);
847 if (ACPI_FAILURE(status)) {
848 return (AE_OK);
851 /* Display the full path */
853 acpi_os_printf("%-32s Type %X", (char *)buffer.pointer, node->type);
854 ACPI_FREE(buffer.pointer);
856 if (info->flags & ACPI_PCI_ROOT_BRIDGE) {
857 acpi_os_printf(" - Is PCI Root Bridge");
859 acpi_os_printf("\n");
861 /* _PRT info */
863 acpi_os_printf("_PRT: %p\n", temp_node);
865 /* Dump _ADR, _HID, _UID, _CID */
867 if (info->valid & ACPI_VALID_ADR) {
868 acpi_os_printf("_ADR: %8.8X%8.8X\n",
869 ACPI_FORMAT_UINT64(info->address));
870 } else {
871 acpi_os_printf("_ADR: <Not Present>\n");
874 if (info->valid & ACPI_VALID_HID) {
875 acpi_os_printf("_HID: %s\n", info->hardware_id.string);
876 } else {
877 acpi_os_printf("_HID: <Not Present>\n");
880 if (info->valid & ACPI_VALID_UID) {
881 acpi_os_printf("_UID: %s\n", info->unique_id.string);
882 } else {
883 acpi_os_printf("_UID: <Not Present>\n");
886 if (info->valid & ACPI_VALID_CID) {
887 for (i = 0; i < info->compatible_id_list.count; i++) {
888 acpi_os_printf("_CID: %s\n",
889 info->compatible_id_list.ids[i].string);
891 } else {
892 acpi_os_printf("_CID: <Not Present>\n");
895 ACPI_FREE(info);
896 return (AE_OK);
899 /*******************************************************************************
901 * FUNCTION: acpi_db_get_bus_info
903 * PARAMETERS: None
905 * RETURN: None
907 * DESCRIPTION: Display info about system busses.
909 ******************************************************************************/
911 void acpi_db_get_bus_info(void)
913 /* Search all nodes in namespace */
915 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
916 ACPI_UINT32_MAX, acpi_db_bus_walk, NULL, NULL,
917 NULL);