iotrace.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2014 Google, Inc
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. #include <iotrace.h>
  8. static void do_print_stats(void)
  9. {
  10. ulong start, size, offset, count;
  11. printf("iotrace is %sabled\n", iotrace_get_enabled() ? "en" : "dis");
  12. iotrace_get_buffer(&start, &size, &offset, &count);
  13. printf("Start: %08lx\n", start);
  14. printf("Size: %08lx\n", size);
  15. printf("Offset: %08lx\n", offset);
  16. printf("Output: %08lx\n", start + offset);
  17. printf("Count: %08lx\n", count);
  18. printf("CRC32: %08lx\n", (ulong)iotrace_get_checksum());
  19. }
  20. static int do_set_buffer(int argc, char * const argv[])
  21. {
  22. ulong addr = 0, size = 0;
  23. if (argc == 2) {
  24. addr = simple_strtoul(*argv++, NULL, 16);
  25. size = simple_strtoul(*argv++, NULL, 16);
  26. } else if (argc != 0) {
  27. return CMD_RET_USAGE;
  28. }
  29. iotrace_set_buffer(addr, size);
  30. return 0;
  31. }
  32. int do_iotrace(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  33. {
  34. const char *cmd = argc < 2 ? NULL : argv[1];
  35. if (!cmd)
  36. return cmd_usage(cmdtp);
  37. switch (*cmd) {
  38. case 'b':
  39. return do_set_buffer(argc - 2, argv + 2);
  40. case 'p':
  41. iotrace_set_enabled(0);
  42. break;
  43. case 'r':
  44. iotrace_set_enabled(1);
  45. break;
  46. case 's':
  47. do_print_stats();
  48. break;
  49. default:
  50. return CMD_RET_USAGE;
  51. }
  52. return 0;
  53. }
  54. U_BOOT_CMD(
  55. iotrace, 4, 1, do_iotrace,
  56. "iotrace utility commands",
  57. "stats - display iotrace stats\n"
  58. "iotrace buffer <address> <size> - set iotrace buffer\n"
  59. "iotrace pause - pause tracing\n"
  60. "iotrace resume - resume tracing"
  61. );