]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
aa53233a SG |
2 | /* |
3 | * Copyright (c) 2014 Google, Inc | |
aa53233a SG |
4 | */ |
5 | ||
6 | #include <common.h> | |
7 | #include <command.h> | |
8 | #include <iotrace.h> | |
9 | ||
10 | static void do_print_stats(void) | |
11 | { | |
e0212dfa | 12 | ulong start, size, needed_size, offset, count; |
aa53233a SG |
13 | |
14 | printf("iotrace is %sabled\n", iotrace_get_enabled() ? "en" : "dis"); | |
e0212dfa | 15 | iotrace_get_buffer(&start, &size, &needed_size, &offset, &count); |
aa53233a | 16 | printf("Start: %08lx\n", start); |
e0212dfa RF |
17 | printf("Actual Size: %08lx\n", size); |
18 | printf("Needed Size: %08lx\n", needed_size); | |
b559c4af RF |
19 | iotrace_get_region(&start, &size); |
20 | printf("Region: %08lx\n", start); | |
21 | printf("Size: %08lx\n", size); | |
aa53233a SG |
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()); | |
26 | } | |
27 | ||
501c89d3 RF |
28 | static void do_print_trace(void) |
29 | { | |
e0212dfa | 30 | ulong start, size, needed_size, offset, count; |
501c89d3 RF |
31 | |
32 | struct iotrace_record *cur_record; | |
33 | ||
e0212dfa | 34 | iotrace_get_buffer(&start, &size, &needed_size, &offset, &count); |
501c89d3 RF |
35 | |
36 | if (!start || !size || !count) | |
37 | return; | |
38 | ||
39 | printf("Timestamp Value Address\n"); | |
40 | ||
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, | |
46 | cur_record->value, | |
47 | (unsigned long long)cur_record->addr); | |
48 | else | |
49 | printf("%08llu: 0x%08lx <-- 0x%08llx\n", | |
50 | cur_record->timestamp, | |
51 | cur_record->value, | |
52 | (unsigned long long)cur_record->addr); | |
53 | ||
54 | cur_record++; | |
55 | } | |
56 | } | |
57 | ||
09140113 | 58 | static int do_set_buffer(int argc, char *const argv[]) |
aa53233a SG |
59 | { |
60 | ulong addr = 0, size = 0; | |
61 | ||
62 | if (argc == 2) { | |
7e5f460e SG |
63 | addr = hextoul(*argv++, NULL); |
64 | size = hextoul(*argv++, NULL); | |
aa53233a SG |
65 | } else if (argc != 0) { |
66 | return CMD_RET_USAGE; | |
67 | } | |
68 | ||
69 | iotrace_set_buffer(addr, size); | |
70 | ||
71 | return 0; | |
72 | } | |
73 | ||
09140113 | 74 | static int do_set_region(int argc, char *const argv[]) |
b559c4af RF |
75 | { |
76 | ulong addr = 0, size = 0; | |
77 | ||
78 | if (argc == 2) { | |
7e5f460e SG |
79 | addr = hextoul(*argv++, NULL); |
80 | size = hextoul(*argv++, NULL); | |
b559c4af RF |
81 | } else if (argc != 0) { |
82 | return CMD_RET_USAGE; | |
83 | } | |
84 | ||
85 | iotrace_set_region(addr, size); | |
86 | ||
87 | return 0; | |
88 | } | |
89 | ||
09140113 | 90 | int do_iotrace(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
aa53233a SG |
91 | { |
92 | const char *cmd = argc < 2 ? NULL : argv[1]; | |
93 | ||
94 | if (!cmd) | |
95 | return cmd_usage(cmdtp); | |
96 | switch (*cmd) { | |
97 | case 'b': | |
98 | return do_set_buffer(argc - 2, argv + 2); | |
b559c4af RF |
99 | case 'l': |
100 | return do_set_region(argc - 2, argv + 2); | |
aa53233a SG |
101 | case 'p': |
102 | iotrace_set_enabled(0); | |
103 | break; | |
104 | case 'r': | |
105 | iotrace_set_enabled(1); | |
106 | break; | |
107 | case 's': | |
108 | do_print_stats(); | |
109 | break; | |
501c89d3 RF |
110 | case 'd': |
111 | do_print_trace(); | |
112 | break; | |
aa53233a SG |
113 | default: |
114 | return CMD_RET_USAGE; | |
115 | } | |
116 | ||
117 | return 0; | |
118 | } | |
119 | ||
120 | U_BOOT_CMD( | |
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" | |
b559c4af | 125 | "iotrace limit <address> <size> - set iotrace region limit\n" |
aa53233a | 126 | "iotrace pause - pause tracing\n" |
501c89d3 RF |
127 | "iotrace resume - resume tracing\n" |
128 | "iotrace dump - dump iotrace buffer" | |
aa53233a | 129 | ); |