1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2014 Google, Inc
10 static void do_print_stats(void)
12 ulong start, size, offset, count;
14 printf("iotrace is %sabled\n", iotrace_get_enabled() ? "en" : "dis");
15 iotrace_get_buffer(&start, &size, &offset, &count);
16 printf("Start: %08lx\n", start);
17 printf("Size: %08lx\n", size);
18 iotrace_get_region(&start, &size);
19 printf("Region: %08lx\n", start);
20 printf("Size: %08lx\n", size);
21 printf("Offset: %08lx\n", offset);
22 printf("Output: %08lx\n", start + offset);
23 printf("Count: %08lx\n", count);
24 printf("CRC32: %08lx\n", (ulong)iotrace_get_checksum());
27 static void do_print_trace(void)
29 ulong start, size, offset, count;
31 struct iotrace_record *cur_record;
33 iotrace_get_buffer(&start, &size, &offset, &count);
35 if (!start || !size || !count)
38 printf("Timestamp Value Address\n");
40 cur_record = (struct iotrace_record *)start;
41 for (int i = 0; i < count; i++) {
42 if (cur_record->flags & IOT_WRITE)
43 printf("%08llu: 0x%08lx --> 0x%08llx\n",
44 cur_record->timestamp,
46 (unsigned long long)cur_record->addr);
48 printf("%08llu: 0x%08lx <-- 0x%08llx\n",
49 cur_record->timestamp,
51 (unsigned long long)cur_record->addr);
57 static int do_set_buffer(int argc, char * const argv[])
59 ulong addr = 0, size = 0;
62 addr = simple_strtoul(*argv++, NULL, 16);
63 size = simple_strtoul(*argv++, NULL, 16);
64 } else if (argc != 0) {
68 iotrace_set_buffer(addr, size);
73 static int do_set_region(int argc, char * const argv[])
75 ulong addr = 0, size = 0;
78 addr = simple_strtoul(*argv++, NULL, 16);
79 size = simple_strtoul(*argv++, NULL, 16);
80 } else if (argc != 0) {
84 iotrace_set_region(addr, size);
89 int do_iotrace(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
91 const char *cmd = argc < 2 ? NULL : argv[1];
94 return cmd_usage(cmdtp);
97 return do_set_buffer(argc - 2, argv + 2);
99 return do_set_region(argc - 2, argv + 2);
101 iotrace_set_enabled(0);
104 iotrace_set_enabled(1);
113 return CMD_RET_USAGE;
120 iotrace, 4, 1, do_iotrace,
121 "iotrace utility commands",
122 "stats - display iotrace stats\n"
123 "iotrace buffer <address> <size> - set iotrace buffer\n"
124 "iotrace limit <address> <size> - set iotrace region limit\n"
125 "iotrace pause - pause tracing\n"
126 "iotrace resume - resume tracing\n"
127 "iotrace dump - dump iotrace buffer"