dump.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2015 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <mapmem.h>
  9. #include <dm/root.h>
  10. #include <dm/util.h>
  11. static void show_devices(struct udevice *dev, int depth, int last_flag)
  12. {
  13. int i, is_last;
  14. struct udevice *child;
  15. /* print the first 11 characters to not break the tree-format. */
  16. printf(" %-10.10s [ %c ] %-10.10s ", dev->uclass->uc_drv->name,
  17. dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name);
  18. for (i = depth; i >= 0; i--) {
  19. is_last = (last_flag >> i) & 1;
  20. if (i) {
  21. if (is_last)
  22. printf(" ");
  23. else
  24. printf("| ");
  25. } else {
  26. if (is_last)
  27. printf("`-- ");
  28. else
  29. printf("|-- ");
  30. }
  31. }
  32. printf("%s\n", dev->name);
  33. list_for_each_entry(child, &dev->child_head, sibling_node) {
  34. is_last = list_is_last(&child->sibling_node, &dev->child_head);
  35. show_devices(child, depth + 1, (last_flag << 1) | is_last);
  36. }
  37. }
  38. void dm_dump_all(void)
  39. {
  40. struct udevice *root;
  41. root = dm_root();
  42. if (root) {
  43. printf(" Class Probed Driver Name\n");
  44. printf("----------------------------------------\n");
  45. show_devices(root, -1, 0);
  46. }
  47. }
  48. /**
  49. * dm_display_line() - Display information about a single device
  50. *
  51. * Displays a single line of information with an option prefix
  52. *
  53. * @dev: Device to display
  54. */
  55. static void dm_display_line(struct udevice *dev)
  56. {
  57. printf("- %c %s @ %08lx",
  58. dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
  59. dev->name, (ulong)map_to_sysmem(dev));
  60. if (dev->seq != -1 || dev->req_seq != -1)
  61. printf(", seq %d, (req %d)", dev->seq, dev->req_seq);
  62. puts("\n");
  63. }
  64. void dm_dump_uclass(void)
  65. {
  66. struct uclass *uc;
  67. int ret;
  68. int id;
  69. for (id = 0; id < UCLASS_COUNT; id++) {
  70. struct udevice *dev;
  71. ret = uclass_get(id, &uc);
  72. if (ret)
  73. continue;
  74. printf("uclass %d: %s\n", id, uc->uc_drv->name);
  75. if (list_empty(&uc->dev_head))
  76. continue;
  77. list_for_each_entry(dev, &uc->dev_head, uclass_node) {
  78. dm_display_line(dev);
  79. }
  80. puts("\n");
  81. }
  82. }