1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
|
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/*******************************************************************************
*
* Module Name: dbnames - Debugger commands for the acpi namespace
*
******************************************************************************/
#include <acpi/acpi.h>
#include "accommon.h"
#include "acnamesp.h"
#include "acdebug.h"
#include "acpredef.h"
#include "acinterp.h"
#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME("dbnames")
/* Local prototypes */
static acpi_status
acpi_db_walk_and_match_name(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value);
static acpi_status
acpi_db_walk_for_predefined_names(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value);
static acpi_status
acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value);
static acpi_status
acpi_db_walk_for_object_counts(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value);
static acpi_status
acpi_db_integrity_walk(acpi_handle obj_handle,
u32 nesting_level, void *context, void **return_value);
static acpi_status
acpi_db_walk_for_references(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value);
static acpi_status
acpi_db_bus_walk(acpi_handle obj_handle,
u32 nesting_level, void *context, void **return_value);
/*
* Arguments for the Objects command
* These object types map directly to the ACPI_TYPES
*/
static struct acpi_db_argument_info acpi_db_object_types[] = {
{"ANY"},
{"INTEGERS"},
{"STRINGS"},
{"BUFFERS"},
{"PACKAGES"},
{"FIELDS"},
{"DEVICES"},
{"EVENTS"},
{"METHODS"},
{"MUTEXES"},
{"REGIONS"},
{"POWERRESOURCES"},
{"PROCESSORS"},
{"THERMALZONES"},
{"BUFFERFIELDS"},
{"DDBHANDLES"},
{"DEBUG"},
{"REGIONFIELDS"},
{"BANKFIELDS"},
{"INDEXFIELDS"},
{"REFERENCES"},
{"ALIASES"},
{"METHODALIASES"},
{"NOTIFY"},
{"ADDRESSHANDLER"},
{"RESOURCE"},
{"RESOURCEFIELD"},
{"SCOPES"},
{NULL} /* Must be null terminated */
};
/*******************************************************************************
*
* FUNCTION: acpi_db_set_scope
*
* PARAMETERS: name - New scope path
*
* RETURN: Status
*
* DESCRIPTION: Set the "current scope" as maintained by this utility.
* The scope is used as a prefix to ACPI paths.
*
******************************************************************************/
void acpi_db_set_scope(char *name)
{
acpi_status status;
struct acpi_namespace_node *node;
if (!name || name[0] == 0) {
acpi_os_printf("Current scope: %s\n", acpi_gbl_db_scope_buf);
return;
}
acpi_db_prep_namestring(name);
if (ACPI_IS_ROOT_PREFIX(name[0])) {
/* Validate new scope from the root */
status = acpi_ns_get_node(acpi_gbl_root_node, name,
ACPI_NS_NO_UPSEARCH, &node);
if (ACPI_FAILURE(status)) {
goto error_exit;
}
acpi_gbl_db_scope_buf[0] = 0;
} else {
/* Validate new scope relative to old scope */
status = acpi_ns_get_node(acpi_gbl_db_scope_node, name,
ACPI_NS_NO_UPSEARCH, &node);
if (ACPI_FAILURE(status)) {
goto error_exit;
}
}
/* Build the final pathname */
if (acpi_ut_safe_strcat
(acpi_gbl_db_scope_buf, sizeof(acpi_gbl_db_scope_buf), name)) {
status = AE_BUFFER_OVERFLOW;
goto error_exit;
}
if (acpi_ut_safe_strcat
(acpi_gbl_db_scope_buf, sizeof(acpi_gbl_db_scope_buf), "\\")) {
status = AE_BUFFER_OVERFLOW;
goto error_exit;
}
acpi_gbl_db_scope_node = node;
acpi_os_printf("New scope: %s\n", acpi_gbl_db_scope_buf);
return;
error_exit:
acpi_os_printf("Could not attach scope: %s, %s\n",
name, acpi_format_exception(status));
}
/*******************************************************************************
*
* FUNCTION: acpi_db_dump_namespace
*
* PARAMETERS: start_arg - Node to begin namespace dump
* depth_arg - Maximum tree depth to be dumped
*
* RETURN: None
*
* DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
* with type and other information.
*
******************************************************************************/
void acpi_db_dump_namespace(char *start_arg, char *depth_arg)
{
acpi_handle subtree_entry = acpi_gbl_root_node;
u32 max_depth = ACPI_UINT32_MAX;
/* No argument given, just start at the root and dump entire namespace */
if (start_arg) {
subtree_entry = acpi_db_convert_to_node(start_arg);
if (!subtree_entry) {
return;
}
/* Now we can check for the depth argument */
if (depth_arg) {
max_depth = strtoul(depth_arg, NULL, 0);
}
}
acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
if (((struct acpi_namespace_node *)subtree_entry)->parent) {
acpi_os_printf("ACPI Namespace (from %4.4s (%p) subtree):\n",
((struct acpi_namespace_node *)subtree_entry)->
name.ascii, subtree_entry);
} else {
acpi_os_printf("ACPI Namespace (from %s):\n",
ACPI_NAMESPACE_ROOT);
}
/* Display the subtree */
acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth,
ACPI_OWNER_ID_MAX, subtree_entry);
acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_dump_namespace_paths
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Dump entire namespace with full object pathnames and object
* type information. Alternative to "namespace" command.
*
******************************************************************************/
void acpi_db_dump_namespace_paths(void)
{
acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
acpi_os_printf("ACPI Namespace (from root):\n");
/* Display the entire namespace */
acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
acpi_ns_dump_object_paths(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY,
ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX,
acpi_gbl_root_node);
acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_dump_namespace_by_owner
*
* PARAMETERS: owner_arg - Owner ID whose nodes will be displayed
* depth_arg - Maximum tree depth to be dumped
*
* RETURN: None
*
* DESCRIPTION: Dump elements of the namespace that are owned by the owner_id.
*
******************************************************************************/
void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg)
{
acpi_handle subtree_entry = acpi_gbl_root_node;
u32 max_depth = ACPI_UINT32_MAX;
acpi_owner_id owner_id;
owner_id = (acpi_owner_id)strtoul(owner_arg, NULL, 0);
/* Now we can check for the depth argument */
if (depth_arg) {
max_depth = strtoul(depth_arg, NULL, 0);
}
acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
acpi_os_printf("ACPI Namespace by owner %X:\n", owner_id);
/* Display the subtree */
acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth,
owner_id, subtree_entry);
acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_walk_and_match_name
*
* PARAMETERS: Callback from walk_namespace
*
* RETURN: Status
*
* DESCRIPTION: Find a particular name/names within the namespace. Wildcards
* are supported -- '?' matches any character.
*
******************************************************************************/
static acpi_status
acpi_db_walk_and_match_name(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value)
{
acpi_status status;
char *requested_name = (char *)context;
u32 i;
struct acpi_buffer buffer;
struct acpi_walk_info info;
/* Check for a name match */
for (i = 0; i < 4; i++) {
/* Wildcard support */
if ((requested_name[i] != '?') &&
(requested_name[i] != ((struct acpi_namespace_node *)
obj_handle)->name.ascii[i])) {
/* No match, just exit */
return (AE_OK);
}
}
/* Get the full pathname to this object */
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
if (ACPI_FAILURE(status)) {
acpi_os_printf("Could Not get pathname for object %p\n",
obj_handle);
} else {
info.count = 0;
info.owner_id = ACPI_OWNER_ID_MAX;
info.debug_level = ACPI_UINT32_MAX;
info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
acpi_os_printf("%32s", (char *)buffer.pointer);
(void)acpi_ns_dump_one_object(obj_handle, nesting_level, &info,
NULL);
ACPI_FREE(buffer.pointer);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_find_name_in_namespace
*
* PARAMETERS: name_arg - The 4-character ACPI name to find.
* wildcards are supported.
*
* RETURN: None
*
* DESCRIPTION: Search the namespace for a given name (with wildcards)
*
******************************************************************************/
acpi_status acpi_db_find_name_in_namespace(char *name_arg)
{
char acpi_name[5] = "____";
char *acpi_name_ptr = acpi_name;
if (strlen(name_arg) > ACPI_NAMESEG_SIZE) {
acpi_os_printf("Name must be no longer than 4 characters\n");
return (AE_OK);
}
/* Pad out name with underscores as necessary to create a 4-char name */
acpi_ut_strupr(name_arg);
while (*name_arg) {
*acpi_name_ptr = *name_arg;
acpi_name_ptr++;
name_arg++;
}
/* Walk the namespace from the root */
(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, acpi_db_walk_and_match_name,
NULL, acpi_name, NULL);
acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_walk_for_predefined_names
*
* PARAMETERS: Callback from walk_namespace
*
* RETURN: Status
*
* DESCRIPTION: Detect and display predefined ACPI names (names that start with
* an underscore)
*
******************************************************************************/
static acpi_status
acpi_db_walk_for_predefined_names(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value)
{
struct acpi_namespace_node *node =
(struct acpi_namespace_node *)obj_handle;
u32 *count = (u32 *)context;
const union acpi_predefined_info *predefined;
const union acpi_predefined_info *package = NULL;
char *pathname;
char string_buffer[48];
predefined = acpi_ut_match_predefined_method(node->name.ascii);
if (!predefined) {
return (AE_OK);
}
pathname = acpi_ns_get_normalized_pathname(node, TRUE);
if (!pathname) {
return (AE_OK);
}
/* If method returns a package, the info is in the next table entry */
if (predefined->info.expected_btypes & ACPI_RTYPE_PACKAGE) {
package = predefined + 1;
}
acpi_ut_get_expected_return_types(string_buffer,
predefined->info.expected_btypes);
acpi_os_printf("%-32s Arguments %X, Return Types: %s", pathname,
METHOD_GET_ARG_COUNT(predefined->info.argument_list),
string_buffer);
if (package) {
acpi_os_printf(" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)",
package->ret_info.type,
package->ret_info.object_type1,
package->ret_info.count1);
}
acpi_os_printf("\n");
/* Check that the declared argument count matches the ACPI spec */
acpi_ns_check_acpi_compliance(pathname, node, predefined);
ACPI_FREE(pathname);
(*count)++;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_check_predefined_names
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Validate all predefined names in the namespace
*
******************************************************************************/
void acpi_db_check_predefined_names(void)
{
u32 count = 0;
/* Search all nodes in namespace */
(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
acpi_db_walk_for_predefined_names, NULL,
(void *)&count, NULL);
acpi_os_printf("Found %u predefined names in the namespace\n", count);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_walk_for_object_counts
*
* PARAMETERS: Callback from walk_namespace
*
* RETURN: Status
*
* DESCRIPTION: Display short info about objects in the namespace
*
******************************************************************************/
static acpi_status
acpi_db_walk_for_object_counts(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value)
{
struct acpi_object_info *info = (struct acpi_object_info *)context;
struct acpi_namespace_node *node =
(struct acpi_namespace_node *)obj_handle;
if (node->type > ACPI_TYPE_NS_NODE_MAX) {
acpi_os_printf("[%4.4s]: Unknown object type %X\n",
node->name.ascii, node->type);
} else {
info->types[node->type]++;
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_walk_for_fields
*
* PARAMETERS: Callback from walk_namespace
*
* RETURN: Status
*
* DESCRIPTION: Display short info about objects in the namespace
*
******************************************************************************/
static acpi_status
acpi_db_walk_for_fields(acpi_handle obj_handle,
u32 nesting_level, void *context, void **return_value)
{
union acpi_object *ret_value;
struct acpi_region_walk_info *info =
(struct acpi_region_walk_info *)context;
struct acpi_buffer buffer;
acpi_status status;
struct acpi_namespace_node *node = acpi_ns_validate_handle(obj_handle);
if (!node) {
return (AE_OK);
}
if (node->object->field.region_obj->region.space_id !=
info->address_space_id) {
return (AE_OK);
}
info->count++;
/* Get and display the full pathname to this object */
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
if (ACPI_FAILURE(status)) {
acpi_os_printf("Could Not get pathname for object %p\n",
obj_handle);
return (AE_OK);
}
acpi_os_printf("%s ", (char *)buffer.pointer);
ACPI_FREE(buffer.pointer);
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
acpi_evaluate_object(obj_handle, NULL, NULL, &buffer);
ret_value = (union acpi_object *)buffer.pointer;
switch (ret_value->type) {
case ACPI_TYPE_INTEGER:
acpi_os_printf("%8.8X%8.8X",
ACPI_FORMAT_UINT64(ret_value->integer.value));
break;
case ACPI_TYPE_BUFFER:
acpi_ut_dump_buffer(ret_value->buffer.pointer,
ret_value->buffer.length,
DB_DISPLAY_DATA_ONLY | DB_BYTE_DISPLAY, 0);
break;
default:
break;
}
acpi_os_printf("\n");
ACPI_FREE(buffer.pointer);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_walk_for_specific_objects
*
* PARAMETERS: Callback from walk_namespace
*
* RETURN: Status
*
* DESCRIPTION: Display short info about objects in the namespace
*
******************************************************************************/
static acpi_status
acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value)
{
struct acpi_walk_info *info = (struct acpi_walk_info *)context;
struct acpi_buffer buffer;
acpi_status status;
info->count++;
/* Get and display the full pathname to this object */
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
if (ACPI_FAILURE(status)) {
acpi_os_printf("Could Not get pathname for object %p\n",
obj_handle);
return (AE_OK);
}
acpi_os_printf("%32s", (char *)buffer.pointer);
ACPI_FREE(buffer.pointer);
/* Dump short info about the object */
(void)acpi_ns_dump_one_object(obj_handle, nesting_level, info, NULL);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_display_objects
*
* PARAMETERS: obj_type_arg - Type of object to display
* display_count_arg - Max depth to display
*
* RETURN: None
*
* DESCRIPTION: Display objects in the namespace of the requested type
*
******************************************************************************/
acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
{
struct acpi_walk_info info;
acpi_object_type type;
struct acpi_object_info *object_info;
u32 i;
u32 total_objects = 0;
/* No argument means display summary/count of all object types */
if (!obj_type_arg) {
object_info =
ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));
/* Walk the namespace from the root */
(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX,
acpi_db_walk_for_object_counts, NULL,
(void *)object_info, NULL);
acpi_os_printf("\nSummary of namespace objects:\n\n");
for (i = 0; i < ACPI_TOTAL_TYPES; i++) {
acpi_os_printf("%8u %s\n", object_info->types[i],
acpi_ut_get_type_name(i));
total_objects += object_info->types[i];
}
acpi_os_printf("\n%8u Total namespace objects\n\n",
total_objects);
ACPI_FREE(object_info);
return (AE_OK);
}
/* Get the object type */
type = acpi_db_match_argument(obj_type_arg, acpi_db_object_types);
if (type == ACPI_TYPE_NOT_FOUND) {
acpi_os_printf("Invalid or unsupported argument\n");
return (AE_OK);
}
acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
acpi_os_printf
("Objects of type [%s] defined in the current ACPI Namespace:\n",
acpi_ut_get_type_name(type));
acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
info.count = 0;
info.owner_id = ACPI_OWNER_ID_MAX;
info.debug_level = ACPI_UINT32_MAX;
info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
/* Walk the namespace from the root */
(void)acpi_walk_namespace(type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
acpi_db_walk_for_specific_objects, NULL,
(void *)&info, NULL);
acpi_os_printf
("\nFound %u objects of type [%s] in the current ACPI Namespace\n",
info.count, acpi_ut_get_type_name(type));
acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_display_fields
*
* PARAMETERS: obj_type_arg - Type of object to display
* display_count_arg - Max depth to display
*
* RETURN: None
*
* DESCRIPTION: Display objects in the namespace of the requested type
*
******************************************************************************/
acpi_status acpi_db_display_fields(u32 address_space_id)
{
struct acpi_region_walk_info info;
info.count = 0;
info.owner_id = ACPI_OWNER_ID_MAX;
info.debug_level = ACPI_UINT32_MAX;
info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
info.address_space_id = address_space_id;
/* Walk the namespace from the root */
(void)acpi_walk_namespace(ACPI_TYPE_LOCAL_REGION_FIELD,
ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
acpi_db_walk_for_fields, NULL, (void *)&info,
NULL);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_integrity_walk
*
* PARAMETERS: Callback from walk_namespace
*
* RETURN: Status
*
* DESCRIPTION: Examine one NS node for valid values.
*
******************************************************************************/
static acpi_status
acpi_db_integrity_walk(acpi_handle obj_handle,
u32 nesting_level, void *context, void **return_value)
{
struct acpi_integrity_info *info =
(struct acpi_integrity_info *)context;
struct acpi_namespace_node *node =
(struct acpi_namespace_node *)obj_handle;
union acpi_operand_object *object;
u8 alias = TRUE;
info->nodes++;
/* Verify the NS node, and dereference aliases */
while (alias) {
if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
acpi_os_printf
("Invalid Descriptor Type for Node %p [%s] - "
"is %2.2X should be %2.2X\n", node,
acpi_ut_get_descriptor_name(node),
ACPI_GET_DESCRIPTOR_TYPE(node),
ACPI_DESC_TYPE_NAMED);
return (AE_OK);
}
if ((node->type == ACPI_TYPE_LOCAL_ALIAS) ||
(node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
node = (struct acpi_namespace_node *)node->object;
} else {
alias = FALSE;
}
}
if (node->type > ACPI_TYPE_LOCAL_MAX) {
acpi_os_printf("Invalid Object Type for Node %p, Type = %X\n",
node, node->type);
return (AE_OK);
}
if (!acpi_ut_valid_nameseg(node->name.ascii)) {
acpi_os_printf("Invalid AcpiName for Node %p\n", node);
return (AE_OK);
}
object = acpi_ns_get_attached_object(node);
if (object) {
info->objects++;
if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
acpi_os_printf
("Invalid Descriptor Type for Object %p [%s]\n",
object, acpi_ut_get_descriptor_name(object));
}
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_check_integrity
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Check entire namespace for data structure integrity
*
******************************************************************************/
void acpi_db_check_integrity(void)
{
struct acpi_integrity_info info = { 0, 0 };
/* Search all nodes in namespace */
(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, acpi_db_integrity_walk, NULL,
(void *)&info, NULL);
acpi_os_printf("Verified %u namespace nodes with %u Objects\n",
info.nodes, info.objects);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_walk_for_references
*
* PARAMETERS: Callback from walk_namespace
*
* RETURN: Status
*
* DESCRIPTION: Check if this namespace object refers to the target object
* that is passed in as the context value.
*
* Note: Currently doesn't check subobjects within the Node's object
*
******************************************************************************/
static acpi_status
acpi_db_walk_for_references(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value)
{
union acpi_operand_object *obj_desc =
(union acpi_operand_object *)context;
struct acpi_namespace_node *node =
(struct acpi_namespace_node *)obj_handle;
/* Check for match against the namespace node itself */
if (node == (void *)obj_desc) {
acpi_os_printf("Object is a Node [%4.4s]\n",
acpi_ut_get_node_name(node));
}
/* Check for match against the object attached to the node */
if (acpi_ns_get_attached_object(node) == obj_desc) {
acpi_os_printf("Reference at Node->Object %p [%4.4s]\n",
node, acpi_ut_get_node_name(node));
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_find_references
*
* PARAMETERS: object_arg - String with hex value of the object
*
* RETURN: None
*
* DESCRIPTION: Search namespace for all references to the input object
*
******************************************************************************/
void acpi_db_find_references(char *object_arg)
{
union acpi_operand_object *obj_desc;
acpi_size address;
/* Convert string to object pointer */
address = strtoul(object_arg, NULL, 16);
obj_desc = ACPI_TO_POINTER(address);
/* Search all nodes in namespace */
(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, acpi_db_walk_for_references,
NULL, (void *)obj_desc, NULL);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_bus_walk
*
* PARAMETERS: Callback from walk_namespace
*
* RETURN: Status
*
* DESCRIPTION: Display info about device objects that have a corresponding
* _PRT method.
*
******************************************************************************/
static acpi_status
acpi_db_bus_walk(acpi_handle obj_handle,
u32 nesting_level, void *context, void **return_value)
{
struct acpi_namespace_node *node =
(struct acpi_namespace_node *)obj_handle;
acpi_status status;
struct acpi_buffer buffer;
struct acpi_namespace_node *temp_node;
struct acpi_device_info *info;
u32 i;
if ((node->type != ACPI_TYPE_DEVICE) &&
(node->type != ACPI_TYPE_PROCESSOR)) {
return (AE_OK);
}
/* Exit if there is no _PRT under this device */
status = acpi_get_handle(node, METHOD_NAME__PRT,
ACPI_CAST_PTR(acpi_handle, &temp_node));
if (ACPI_FAILURE(status)) {
return (AE_OK);
}
/* Get the full path to this device object */
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
if (ACPI_FAILURE(status)) {
acpi_os_printf("Could Not get pathname for object %p\n",
obj_handle);
return (AE_OK);
}
status = acpi_get_object_info(obj_handle, &info);
if (ACPI_FAILURE(status)) {
return (AE_OK);
}
/* Display the full path */
acpi_os_printf("%-32s Type %X", (char *)buffer.pointer, node->type);
ACPI_FREE(buffer.pointer);
if (info->flags & ACPI_PCI_ROOT_BRIDGE) {
acpi_os_printf(" - Is PCI Root Bridge");
}
acpi_os_printf("\n");
/* _PRT info */
acpi_os_printf("_PRT: %p\n", temp_node);
/* Dump _ADR, _HID, _UID, _CID */
if (info->valid & ACPI_VALID_ADR) {
acpi_os_printf("_ADR: %8.8X%8.8X\n",
ACPI_FORMAT_UINT64(info->address));
} else {
acpi_os_printf("_ADR: <Not Present>\n");
}
if (info->valid & ACPI_VALID_HID) {
acpi_os_printf("_HID: %s\n", info->hardware_id.string);
} else {
acpi_os_printf("_HID: <Not Present>\n");
}
if (info->valid & ACPI_VALID_UID) {
acpi_os_printf("_UID: %s\n", info->unique_id.string);
} else {
acpi_os_printf("_UID: <Not Present>\n");
}
if (info->valid & ACPI_VALID_CID) {
for (i = 0; i < info->compatible_id_list.count; i++) {
acpi_os_printf("_CID: %s\n",
info->compatible_id_list.ids[i].string);
}
} else {
acpi_os_printf("_CID: <Not Present>\n");
}
ACPI_FREE(info);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_get_bus_info
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display info about system buses.
*
******************************************************************************/
void acpi_db_get_bus_info(void)
{
/* Search all nodes in namespace */
(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, acpi_db_bus_walk, NULL, NULL,
NULL);
}
|