dbnames.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /*******************************************************************************
  3. *
  4. * Module Name: dbnames - Debugger commands for the acpi namespace
  5. *
  6. ******************************************************************************/
  7. #include <acpi/acpi.h>
  8. #include "accommon.h"
  9. #include "acnamesp.h"
  10. #include "acdebug.h"
  11. #include "acpredef.h"
  12. #define _COMPONENT ACPI_CA_DEBUGGER
  13. ACPI_MODULE_NAME("dbnames")
  14. /* Local prototypes */
  15. static acpi_status
  16. acpi_db_walk_and_match_name(acpi_handle obj_handle,
  17. u32 nesting_level,
  18. void *context, void **return_value);
  19. static acpi_status
  20. acpi_db_walk_for_predefined_names(acpi_handle obj_handle,
  21. u32 nesting_level,
  22. void *context, void **return_value);
  23. static acpi_status
  24. acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
  25. u32 nesting_level,
  26. void *context, void **return_value);
  27. static acpi_status
  28. acpi_db_walk_for_object_counts(acpi_handle obj_handle,
  29. u32 nesting_level,
  30. void *context, void **return_value);
  31. static acpi_status
  32. acpi_db_integrity_walk(acpi_handle obj_handle,
  33. u32 nesting_level, void *context, void **return_value);
  34. static acpi_status
  35. acpi_db_walk_for_references(acpi_handle obj_handle,
  36. u32 nesting_level,
  37. void *context, void **return_value);
  38. static acpi_status
  39. acpi_db_bus_walk(acpi_handle obj_handle,
  40. u32 nesting_level, void *context, void **return_value);
  41. /*
  42. * Arguments for the Objects command
  43. * These object types map directly to the ACPI_TYPES
  44. */
  45. static struct acpi_db_argument_info acpi_db_object_types[] = {
  46. {"ANY"},
  47. {"INTEGERS"},
  48. {"STRINGS"},
  49. {"BUFFERS"},
  50. {"PACKAGES"},
  51. {"FIELDS"},
  52. {"DEVICES"},
  53. {"EVENTS"},
  54. {"METHODS"},
  55. {"MUTEXES"},
  56. {"REGIONS"},
  57. {"POWERRESOURCES"},
  58. {"PROCESSORS"},
  59. {"THERMALZONES"},
  60. {"BUFFERFIELDS"},
  61. {"DDBHANDLES"},
  62. {"DEBUG"},
  63. {"REGIONFIELDS"},
  64. {"BANKFIELDS"},
  65. {"INDEXFIELDS"},
  66. {"REFERENCES"},
  67. {"ALIASES"},
  68. {"METHODALIASES"},
  69. {"NOTIFY"},
  70. {"ADDRESSHANDLER"},
  71. {"RESOURCE"},
  72. {"RESOURCEFIELD"},
  73. {"SCOPES"},
  74. {NULL} /* Must be null terminated */
  75. };
  76. /*******************************************************************************
  77. *
  78. * FUNCTION: acpi_db_set_scope
  79. *
  80. * PARAMETERS: name - New scope path
  81. *
  82. * RETURN: Status
  83. *
  84. * DESCRIPTION: Set the "current scope" as maintained by this utility.
  85. * The scope is used as a prefix to ACPI paths.
  86. *
  87. ******************************************************************************/
  88. void acpi_db_set_scope(char *name)
  89. {
  90. acpi_status status;
  91. struct acpi_namespace_node *node;
  92. if (!name || name[0] == 0) {
  93. acpi_os_printf("Current scope: %s\n", acpi_gbl_db_scope_buf);
  94. return;
  95. }
  96. acpi_db_prep_namestring(name);
  97. if (ACPI_IS_ROOT_PREFIX(name[0])) {
  98. /* Validate new scope from the root */
  99. status = acpi_ns_get_node(acpi_gbl_root_node, name,
  100. ACPI_NS_NO_UPSEARCH, &node);
  101. if (ACPI_FAILURE(status)) {
  102. goto error_exit;
  103. }
  104. acpi_gbl_db_scope_buf[0] = 0;
  105. } else {
  106. /* Validate new scope relative to old scope */
  107. status = acpi_ns_get_node(acpi_gbl_db_scope_node, name,
  108. ACPI_NS_NO_UPSEARCH, &node);
  109. if (ACPI_FAILURE(status)) {
  110. goto error_exit;
  111. }
  112. }
  113. /* Build the final pathname */
  114. if (acpi_ut_safe_strcat
  115. (acpi_gbl_db_scope_buf, sizeof(acpi_gbl_db_scope_buf), name)) {
  116. status = AE_BUFFER_OVERFLOW;
  117. goto error_exit;
  118. }
  119. if (acpi_ut_safe_strcat
  120. (acpi_gbl_db_scope_buf, sizeof(acpi_gbl_db_scope_buf), "\\")) {
  121. status = AE_BUFFER_OVERFLOW;
  122. goto error_exit;
  123. }
  124. acpi_gbl_db_scope_node = node;
  125. acpi_os_printf("New scope: %s\n", acpi_gbl_db_scope_buf);
  126. return;
  127. error_exit:
  128. acpi_os_printf("Could not attach scope: %s, %s\n",
  129. name, acpi_format_exception(status));
  130. }
  131. /*******************************************************************************
  132. *
  133. * FUNCTION: acpi_db_dump_namespace
  134. *
  135. * PARAMETERS: start_arg - Node to begin namespace dump
  136. * depth_arg - Maximum tree depth to be dumped
  137. *
  138. * RETURN: None
  139. *
  140. * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
  141. * with type and other information.
  142. *
  143. ******************************************************************************/
  144. void acpi_db_dump_namespace(char *start_arg, char *depth_arg)
  145. {
  146. acpi_handle subtree_entry = acpi_gbl_root_node;
  147. u32 max_depth = ACPI_UINT32_MAX;
  148. /* No argument given, just start at the root and dump entire namespace */
  149. if (start_arg) {
  150. subtree_entry = acpi_db_convert_to_node(start_arg);
  151. if (!subtree_entry) {
  152. return;
  153. }
  154. /* Now we can check for the depth argument */
  155. if (depth_arg) {
  156. max_depth = strtoul(depth_arg, NULL, 0);
  157. }
  158. }
  159. acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
  160. acpi_os_printf("ACPI Namespace (from %4.4s (%p) subtree):\n",
  161. ((struct acpi_namespace_node *)subtree_entry)->name.
  162. ascii, subtree_entry);
  163. /* Display the subtree */
  164. acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
  165. acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth,
  166. ACPI_OWNER_ID_MAX, subtree_entry);
  167. acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
  168. }
  169. /*******************************************************************************
  170. *
  171. * FUNCTION: acpi_db_dump_namespace_paths
  172. *
  173. * PARAMETERS: None
  174. *
  175. * RETURN: None
  176. *
  177. * DESCRIPTION: Dump entire namespace with full object pathnames and object
  178. * type information. Alternative to "namespace" command.
  179. *
  180. ******************************************************************************/
  181. void acpi_db_dump_namespace_paths(void)
  182. {
  183. acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
  184. acpi_os_printf("ACPI Namespace (from root):\n");
  185. /* Display the entire namespace */
  186. acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
  187. acpi_ns_dump_object_paths(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY,
  188. ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX,
  189. acpi_gbl_root_node);
  190. acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
  191. }
  192. /*******************************************************************************
  193. *
  194. * FUNCTION: acpi_db_dump_namespace_by_owner
  195. *
  196. * PARAMETERS: owner_arg - Owner ID whose nodes will be displayed
  197. * depth_arg - Maximum tree depth to be dumped
  198. *
  199. * RETURN: None
  200. *
  201. * DESCRIPTION: Dump elements of the namespace that are owned by the owner_id.
  202. *
  203. ******************************************************************************/
  204. void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg)
  205. {
  206. acpi_handle subtree_entry = acpi_gbl_root_node;
  207. u32 max_depth = ACPI_UINT32_MAX;
  208. acpi_owner_id owner_id;
  209. owner_id = (acpi_owner_id)strtoul(owner_arg, NULL, 0);
  210. /* Now we can check for the depth argument */
  211. if (depth_arg) {
  212. max_depth = strtoul(depth_arg, NULL, 0);
  213. }
  214. acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
  215. acpi_os_printf("ACPI Namespace by owner %X:\n", owner_id);
  216. /* Display the subtree */
  217. acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
  218. acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth,
  219. owner_id, subtree_entry);
  220. acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
  221. }
  222. /*******************************************************************************
  223. *
  224. * FUNCTION: acpi_db_walk_and_match_name
  225. *
  226. * PARAMETERS: Callback from walk_namespace
  227. *
  228. * RETURN: Status
  229. *
  230. * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
  231. * are supported -- '?' matches any character.
  232. *
  233. ******************************************************************************/
  234. static acpi_status
  235. acpi_db_walk_and_match_name(acpi_handle obj_handle,
  236. u32 nesting_level,
  237. void *context, void **return_value)
  238. {
  239. acpi_status status;
  240. char *requested_name = (char *)context;
  241. u32 i;
  242. struct acpi_buffer buffer;
  243. struct acpi_walk_info info;
  244. /* Check for a name match */
  245. for (i = 0; i < 4; i++) {
  246. /* Wildcard support */
  247. if ((requested_name[i] != '?') &&
  248. (requested_name[i] != ((struct acpi_namespace_node *)
  249. obj_handle)->name.ascii[i])) {
  250. /* No match, just exit */
  251. return (AE_OK);
  252. }
  253. }
  254. /* Get the full pathname to this object */
  255. buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
  256. status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
  257. if (ACPI_FAILURE(status)) {
  258. acpi_os_printf("Could Not get pathname for object %p\n",
  259. obj_handle);
  260. } else {
  261. info.owner_id = ACPI_OWNER_ID_MAX;
  262. info.debug_level = ACPI_UINT32_MAX;
  263. info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
  264. acpi_os_printf("%32s", (char *)buffer.pointer);
  265. (void)acpi_ns_dump_one_object(obj_handle, nesting_level, &info,
  266. NULL);
  267. ACPI_FREE(buffer.pointer);
  268. }
  269. return (AE_OK);
  270. }
  271. /*******************************************************************************
  272. *
  273. * FUNCTION: acpi_db_find_name_in_namespace
  274. *
  275. * PARAMETERS: name_arg - The 4-character ACPI name to find.
  276. * wildcards are supported.
  277. *
  278. * RETURN: None
  279. *
  280. * DESCRIPTION: Search the namespace for a given name (with wildcards)
  281. *
  282. ******************************************************************************/
  283. acpi_status acpi_db_find_name_in_namespace(char *name_arg)
  284. {
  285. char acpi_name[5] = "____";
  286. char *acpi_name_ptr = acpi_name;
  287. if (strlen(name_arg) > ACPI_NAME_SIZE) {
  288. acpi_os_printf("Name must be no longer than 4 characters\n");
  289. return (AE_OK);
  290. }
  291. /* Pad out name with underscores as necessary to create a 4-char name */
  292. acpi_ut_strupr(name_arg);
  293. while (*name_arg) {
  294. *acpi_name_ptr = *name_arg;
  295. acpi_name_ptr++;
  296. name_arg++;
  297. }
  298. /* Walk the namespace from the root */
  299. (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
  300. ACPI_UINT32_MAX, acpi_db_walk_and_match_name,
  301. NULL, acpi_name, NULL);
  302. acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
  303. return (AE_OK);
  304. }
  305. /*******************************************************************************
  306. *
  307. * FUNCTION: acpi_db_walk_for_predefined_names
  308. *
  309. * PARAMETERS: Callback from walk_namespace
  310. *
  311. * RETURN: Status
  312. *
  313. * DESCRIPTION: Detect and display predefined ACPI names (names that start with
  314. * an underscore)
  315. *
  316. ******************************************************************************/
  317. static acpi_status
  318. acpi_db_walk_for_predefined_names(acpi_handle obj_handle,
  319. u32 nesting_level,
  320. void *context, void **return_value)
  321. {
  322. struct acpi_namespace_node *node =
  323. (struct acpi_namespace_node *)obj_handle;
  324. u32 *count = (u32 *)context;
  325. const union acpi_predefined_info *predefined;
  326. const union acpi_predefined_info *package = NULL;
  327. char *pathname;
  328. char string_buffer[48];
  329. predefined = acpi_ut_match_predefined_method(node->name.ascii);
  330. if (!predefined) {
  331. return (AE_OK);
  332. }
  333. pathname = acpi_ns_get_normalized_pathname(node, TRUE);
  334. if (!pathname) {
  335. return (AE_OK);
  336. }
  337. /* If method returns a package, the info is in the next table entry */
  338. if (predefined->info.expected_btypes & ACPI_RTYPE_PACKAGE) {
  339. package = predefined + 1;
  340. }
  341. acpi_ut_get_expected_return_types(string_buffer,
  342. predefined->info.expected_btypes);
  343. acpi_os_printf("%-32s Arguments %X, Return Types: %s", pathname,
  344. METHOD_GET_ARG_COUNT(predefined->info.argument_list),
  345. string_buffer);
  346. if (package) {
  347. acpi_os_printf(" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)",
  348. package->ret_info.type,
  349. package->ret_info.object_type1,
  350. package->ret_info.count1);
  351. }
  352. acpi_os_printf("\n");
  353. /* Check that the declared argument count matches the ACPI spec */
  354. acpi_ns_check_acpi_compliance(pathname, node, predefined);
  355. ACPI_FREE(pathname);
  356. (*count)++;
  357. return (AE_OK);
  358. }
  359. /*******************************************************************************
  360. *
  361. * FUNCTION: acpi_db_check_predefined_names
  362. *
  363. * PARAMETERS: None
  364. *
  365. * RETURN: None
  366. *
  367. * DESCRIPTION: Validate all predefined names in the namespace
  368. *
  369. ******************************************************************************/
  370. void acpi_db_check_predefined_names(void)
  371. {
  372. u32 count = 0;
  373. /* Search all nodes in namespace */
  374. (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
  375. ACPI_UINT32_MAX,
  376. acpi_db_walk_for_predefined_names, NULL,
  377. (void *)&count, NULL);
  378. acpi_os_printf("Found %u predefined names in the namespace\n", count);
  379. }
  380. /*******************************************************************************
  381. *
  382. * FUNCTION: acpi_db_walk_for_object_counts
  383. *
  384. * PARAMETERS: Callback from walk_namespace
  385. *
  386. * RETURN: Status
  387. *
  388. * DESCRIPTION: Display short info about objects in the namespace
  389. *
  390. ******************************************************************************/
  391. static acpi_status
  392. acpi_db_walk_for_object_counts(acpi_handle obj_handle,
  393. u32 nesting_level,
  394. void *context, void **return_value)
  395. {
  396. struct acpi_object_info *info = (struct acpi_object_info *)context;
  397. struct acpi_namespace_node *node =
  398. (struct acpi_namespace_node *)obj_handle;
  399. if (node->type > ACPI_TYPE_NS_NODE_MAX) {
  400. acpi_os_printf("[%4.4s]: Unknown object type %X\n",
  401. node->name.ascii, node->type);
  402. } else {
  403. info->types[node->type]++;
  404. }
  405. return (AE_OK);
  406. }
  407. /*******************************************************************************
  408. *
  409. * FUNCTION: acpi_db_walk_for_specific_objects
  410. *
  411. * PARAMETERS: Callback from walk_namespace
  412. *
  413. * RETURN: Status
  414. *
  415. * DESCRIPTION: Display short info about objects in the namespace
  416. *
  417. ******************************************************************************/
  418. static acpi_status
  419. acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
  420. u32 nesting_level,
  421. void *context, void **return_value)
  422. {
  423. struct acpi_walk_info *info = (struct acpi_walk_info *)context;
  424. struct acpi_buffer buffer;
  425. acpi_status status;
  426. info->count++;
  427. /* Get and display the full pathname to this object */
  428. buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
  429. status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
  430. if (ACPI_FAILURE(status)) {
  431. acpi_os_printf("Could Not get pathname for object %p\n",
  432. obj_handle);
  433. return (AE_OK);
  434. }
  435. acpi_os_printf("%32s", (char *)buffer.pointer);
  436. ACPI_FREE(buffer.pointer);
  437. /* Dump short info about the object */
  438. (void)acpi_ns_dump_one_object(obj_handle, nesting_level, info, NULL);
  439. return (AE_OK);
  440. }
  441. /*******************************************************************************
  442. *
  443. * FUNCTION: acpi_db_display_objects
  444. *
  445. * PARAMETERS: obj_type_arg - Type of object to display
  446. * display_count_arg - Max depth to display
  447. *
  448. * RETURN: None
  449. *
  450. * DESCRIPTION: Display objects in the namespace of the requested type
  451. *
  452. ******************************************************************************/
  453. acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
  454. {
  455. struct acpi_walk_info info;
  456. acpi_object_type type;
  457. struct acpi_object_info *object_info;
  458. u32 i;
  459. u32 total_objects = 0;
  460. /* No argument means display summary/count of all object types */
  461. if (!obj_type_arg) {
  462. object_info =
  463. ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));
  464. /* Walk the namespace from the root */
  465. (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
  466. ACPI_UINT32_MAX,
  467. acpi_db_walk_for_object_counts, NULL,
  468. (void *)object_info, NULL);
  469. acpi_os_printf("\nSummary of namespace objects:\n\n");
  470. for (i = 0; i < ACPI_TOTAL_TYPES; i++) {
  471. acpi_os_printf("%8u %s\n", object_info->types[i],
  472. acpi_ut_get_type_name(i));
  473. total_objects += object_info->types[i];
  474. }
  475. acpi_os_printf("\n%8u Total namespace objects\n\n",
  476. total_objects);
  477. ACPI_FREE(object_info);
  478. return (AE_OK);
  479. }
  480. /* Get the object type */
  481. type = acpi_db_match_argument(obj_type_arg, acpi_db_object_types);
  482. if (type == ACPI_TYPE_NOT_FOUND) {
  483. acpi_os_printf("Invalid or unsupported argument\n");
  484. return (AE_OK);
  485. }
  486. acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
  487. acpi_os_printf
  488. ("Objects of type [%s] defined in the current ACPI Namespace:\n",
  489. acpi_ut_get_type_name(type));
  490. acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
  491. info.count = 0;
  492. info.owner_id = ACPI_OWNER_ID_MAX;
  493. info.debug_level = ACPI_UINT32_MAX;
  494. info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
  495. /* Walk the namespace from the root */
  496. (void)acpi_walk_namespace(type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
  497. acpi_db_walk_for_specific_objects, NULL,
  498. (void *)&info, NULL);
  499. acpi_os_printf
  500. ("\nFound %u objects of type [%s] in the current ACPI Namespace\n",
  501. info.count, acpi_ut_get_type_name(type));
  502. acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
  503. return (AE_OK);
  504. }
  505. /*******************************************************************************
  506. *
  507. * FUNCTION: acpi_db_integrity_walk
  508. *
  509. * PARAMETERS: Callback from walk_namespace
  510. *
  511. * RETURN: Status
  512. *
  513. * DESCRIPTION: Examine one NS node for valid values.
  514. *
  515. ******************************************************************************/
  516. static acpi_status
  517. acpi_db_integrity_walk(acpi_handle obj_handle,
  518. u32 nesting_level, void *context, void **return_value)
  519. {
  520. struct acpi_integrity_info *info =
  521. (struct acpi_integrity_info *)context;
  522. struct acpi_namespace_node *node =
  523. (struct acpi_namespace_node *)obj_handle;
  524. union acpi_operand_object *object;
  525. u8 alias = TRUE;
  526. info->nodes++;
  527. /* Verify the NS node, and dereference aliases */
  528. while (alias) {
  529. if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
  530. acpi_os_printf
  531. ("Invalid Descriptor Type for Node %p [%s] - "
  532. "is %2.2X should be %2.2X\n", node,
  533. acpi_ut_get_descriptor_name(node),
  534. ACPI_GET_DESCRIPTOR_TYPE(node),
  535. ACPI_DESC_TYPE_NAMED);
  536. return (AE_OK);
  537. }
  538. if ((node->type == ACPI_TYPE_LOCAL_ALIAS) ||
  539. (node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
  540. node = (struct acpi_namespace_node *)node->object;
  541. } else {
  542. alias = FALSE;
  543. }
  544. }
  545. if (node->type > ACPI_TYPE_LOCAL_MAX) {
  546. acpi_os_printf("Invalid Object Type for Node %p, Type = %X\n",
  547. node, node->type);
  548. return (AE_OK);
  549. }
  550. if (!acpi_ut_valid_nameseg(node->name.ascii)) {
  551. acpi_os_printf("Invalid AcpiName for Node %p\n", node);
  552. return (AE_OK);
  553. }
  554. object = acpi_ns_get_attached_object(node);
  555. if (object) {
  556. info->objects++;
  557. if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
  558. acpi_os_printf
  559. ("Invalid Descriptor Type for Object %p [%s]\n",
  560. object, acpi_ut_get_descriptor_name(object));
  561. }
  562. }
  563. return (AE_OK);
  564. }
  565. /*******************************************************************************
  566. *
  567. * FUNCTION: acpi_db_check_integrity
  568. *
  569. * PARAMETERS: None
  570. *
  571. * RETURN: None
  572. *
  573. * DESCRIPTION: Check entire namespace for data structure integrity
  574. *
  575. ******************************************************************************/
  576. void acpi_db_check_integrity(void)
  577. {
  578. struct acpi_integrity_info info = { 0, 0 };
  579. /* Search all nodes in namespace */
  580. (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
  581. ACPI_UINT32_MAX, acpi_db_integrity_walk, NULL,
  582. (void *)&info, NULL);
  583. acpi_os_printf("Verified %u namespace nodes with %u Objects\n",
  584. info.nodes, info.objects);
  585. }
  586. /*******************************************************************************
  587. *
  588. * FUNCTION: acpi_db_walk_for_references
  589. *
  590. * PARAMETERS: Callback from walk_namespace
  591. *
  592. * RETURN: Status
  593. *
  594. * DESCRIPTION: Check if this namespace object refers to the target object
  595. * that is passed in as the context value.
  596. *
  597. * Note: Currently doesn't check subobjects within the Node's object
  598. *
  599. ******************************************************************************/
  600. static acpi_status
  601. acpi_db_walk_for_references(acpi_handle obj_handle,
  602. u32 nesting_level,
  603. void *context, void **return_value)
  604. {
  605. union acpi_operand_object *obj_desc =
  606. (union acpi_operand_object *)context;
  607. struct acpi_namespace_node *node =
  608. (struct acpi_namespace_node *)obj_handle;
  609. /* Check for match against the namespace node itself */
  610. if (node == (void *)obj_desc) {
  611. acpi_os_printf("Object is a Node [%4.4s]\n",
  612. acpi_ut_get_node_name(node));
  613. }
  614. /* Check for match against the object attached to the node */
  615. if (acpi_ns_get_attached_object(node) == obj_desc) {
  616. acpi_os_printf("Reference at Node->Object %p [%4.4s]\n",
  617. node, acpi_ut_get_node_name(node));
  618. }
  619. return (AE_OK);
  620. }
  621. /*******************************************************************************
  622. *
  623. * FUNCTION: acpi_db_find_references
  624. *
  625. * PARAMETERS: object_arg - String with hex value of the object
  626. *
  627. * RETURN: None
  628. *
  629. * DESCRIPTION: Search namespace for all references to the input object
  630. *
  631. ******************************************************************************/
  632. void acpi_db_find_references(char *object_arg)
  633. {
  634. union acpi_operand_object *obj_desc;
  635. acpi_size address;
  636. /* Convert string to object pointer */
  637. address = strtoul(object_arg, NULL, 16);
  638. obj_desc = ACPI_TO_POINTER(address);
  639. /* Search all nodes in namespace */
  640. (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
  641. ACPI_UINT32_MAX, acpi_db_walk_for_references,
  642. NULL, (void *)obj_desc, NULL);
  643. }
  644. /*******************************************************************************
  645. *
  646. * FUNCTION: acpi_db_bus_walk
  647. *
  648. * PARAMETERS: Callback from walk_namespace
  649. *
  650. * RETURN: Status
  651. *
  652. * DESCRIPTION: Display info about device objects that have a corresponding
  653. * _PRT method.
  654. *
  655. ******************************************************************************/
  656. static acpi_status
  657. acpi_db_bus_walk(acpi_handle obj_handle,
  658. u32 nesting_level, void *context, void **return_value)
  659. {
  660. struct acpi_namespace_node *node =
  661. (struct acpi_namespace_node *)obj_handle;
  662. acpi_status status;
  663. struct acpi_buffer buffer;
  664. struct acpi_namespace_node *temp_node;
  665. struct acpi_device_info *info;
  666. u32 i;
  667. if ((node->type != ACPI_TYPE_DEVICE) &&
  668. (node->type != ACPI_TYPE_PROCESSOR)) {
  669. return (AE_OK);
  670. }
  671. /* Exit if there is no _PRT under this device */
  672. status = acpi_get_handle(node, METHOD_NAME__PRT,
  673. ACPI_CAST_PTR(acpi_handle, &temp_node));
  674. if (ACPI_FAILURE(status)) {
  675. return (AE_OK);
  676. }
  677. /* Get the full path to this device object */
  678. buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
  679. status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
  680. if (ACPI_FAILURE(status)) {
  681. acpi_os_printf("Could Not get pathname for object %p\n",
  682. obj_handle);
  683. return (AE_OK);
  684. }
  685. status = acpi_get_object_info(obj_handle, &info);
  686. if (ACPI_FAILURE(status)) {
  687. return (AE_OK);
  688. }
  689. /* Display the full path */
  690. acpi_os_printf("%-32s Type %X", (char *)buffer.pointer, node->type);
  691. ACPI_FREE(buffer.pointer);
  692. if (info->flags & ACPI_PCI_ROOT_BRIDGE) {
  693. acpi_os_printf(" - Is PCI Root Bridge");
  694. }
  695. acpi_os_printf("\n");
  696. /* _PRT info */
  697. acpi_os_printf("_PRT: %p\n", temp_node);
  698. /* Dump _ADR, _HID, _UID, _CID */
  699. if (info->valid & ACPI_VALID_ADR) {
  700. acpi_os_printf("_ADR: %8.8X%8.8X\n",
  701. ACPI_FORMAT_UINT64(info->address));
  702. } else {
  703. acpi_os_printf("_ADR: <Not Present>\n");
  704. }
  705. if (info->valid & ACPI_VALID_HID) {
  706. acpi_os_printf("_HID: %s\n", info->hardware_id.string);
  707. } else {
  708. acpi_os_printf("_HID: <Not Present>\n");
  709. }
  710. if (info->valid & ACPI_VALID_UID) {
  711. acpi_os_printf("_UID: %s\n", info->unique_id.string);
  712. } else {
  713. acpi_os_printf("_UID: <Not Present>\n");
  714. }
  715. if (info->valid & ACPI_VALID_CID) {
  716. for (i = 0; i < info->compatible_id_list.count; i++) {
  717. acpi_os_printf("_CID: %s\n",
  718. info->compatible_id_list.ids[i].string);
  719. }
  720. } else {
  721. acpi_os_printf("_CID: <Not Present>\n");
  722. }
  723. ACPI_FREE(info);
  724. return (AE_OK);
  725. }
  726. /*******************************************************************************
  727. *
  728. * FUNCTION: acpi_db_get_bus_info
  729. *
  730. * PARAMETERS: None
  731. *
  732. * RETURN: None
  733. *
  734. * DESCRIPTION: Display info about system busses.
  735. *
  736. ******************************************************************************/
  737. void acpi_db_get_bus_info(void)
  738. {
  739. /* Search all nodes in namespace */
  740. (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
  741. ACPI_UINT32_MAX, acpi_db_bus_walk, NULL, NULL,
  742. NULL);
  743. }