iotrace.c 1.6 KB

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