1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2014 Google, Inc
10 static void do_print_stats(void)
12 ulong start, size, needed_size, offset, count;
14 printf("iotrace is %sabled\n", iotrace_get_enabled() ? "en" : "dis");
15 iotrace_get_buffer(&start, &size, &needed_size, &offset, &count);
16 printf("Start: %08lx\n", start);
17 printf("Actual Size: %08lx\n", size);
18 printf("Needed Size: %08lx\n", needed_size);
19 iotrace_get_region(&start, &size);
20 printf("Region: %08lx\n", start);
21 printf("Size: %08lx\n", size);
22 printf("Offset: %08lx\n", offset);
23 printf("Output: %08lx\n", start + offset);
24 printf("Count: %08lx\n", count);
25 printf("CRC32: %08lx\n", (ulong)iotrace_get_checksum());
28 static void do_print_trace(void)
30 ulong start, size, needed_size, offset, count;
32 struct iotrace_record *cur_record;
34 iotrace_get_buffer(&start, &size, &needed_size, &offset, &count);
36 if (!start || !size || !count)
39 printf("Timestamp Value Address\n");
41 cur_record = (struct iotrace_record *)start;
42 for (int i = 0; i < count; i++) {
43 if (cur_record->flags & IOT_WRITE)
44 printf("%08llu: 0x%08lx --> 0x%08llx\n",
45 cur_record->timestamp,
47 (unsigned long long)cur_record->addr);
49 printf("%08llu: 0x%08lx <-- 0x%08llx\n",
50 cur_record->timestamp,
52 (unsigned long long)cur_record->addr);
58 static int do_set_buffer(int argc, char *const argv[])
60 ulong addr = 0, size = 0;
63 addr = simple_strtoul(*argv++, NULL, 16);
64 size = simple_strtoul(*argv++, NULL, 16);
65 } else if (argc != 0) {
69 iotrace_set_buffer(addr, size);
74 static int do_set_region(int argc, char *const argv[])
76 ulong addr = 0, size = 0;
79 addr = simple_strtoul(*argv++, NULL, 16);
80 size = simple_strtoul(*argv++, NULL, 16);
81 } else if (argc != 0) {
85 iotrace_set_region(addr, size);
90 int do_iotrace(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
92 const char *cmd = argc < 2 ? NULL : argv[1];
95 return cmd_usage(cmdtp);
98 return do_set_buffer(argc - 2, argv + 2);
100 return do_set_region(argc - 2, argv + 2);
102 iotrace_set_enabled(0);
105 iotrace_set_enabled(1);
114 return CMD_RET_USAGE;
121 iotrace, 4, 1, do_iotrace,
122 "iotrace utility commands",
123 "stats - display iotrace stats\n"
124 "iotrace buffer <address> <size> - set iotrace buffer\n"
125 "iotrace limit <address> <size> - set iotrace region limit\n"
126 "iotrace pause - pause tracing\n"
127 "iotrace resume - resume tracing\n"
128 "iotrace dump - dump iotrace buffer"