blob: e496787e0d0e639c1f84173d91628f218088355f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass4dc47ca2014-06-11 23:29:41 -06002/*
3 * Copyright (c) 2014 Google, Inc
Simon Glass4dc47ca2014-06-11 23:29:41 -06004 */
5
6#include <common.h>
7#include <command.h>
8#include <iotrace.h>
9
10static void do_print_stats(void)
11{
12 ulong start, size, offset, count;
13
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 printf("Offset: %08lx\n", offset);
19 printf("Output: %08lx\n", start + offset);
20 printf("Count: %08lx\n", count);
21 printf("CRC32: %08lx\n", (ulong)iotrace_get_checksum());
22}
23
24static int do_set_buffer(int argc, char * const argv[])
25{
26 ulong addr = 0, size = 0;
27
28 if (argc == 2) {
29 addr = simple_strtoul(*argv++, NULL, 16);
30 size = simple_strtoul(*argv++, NULL, 16);
31 } else if (argc != 0) {
32 return CMD_RET_USAGE;
33 }
34
35 iotrace_set_buffer(addr, size);
36
37 return 0;
38}
39
40int do_iotrace(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
41{
42 const char *cmd = argc < 2 ? NULL : argv[1];
43
44 if (!cmd)
45 return cmd_usage(cmdtp);
46 switch (*cmd) {
47 case 'b':
48 return do_set_buffer(argc - 2, argv + 2);
49 case 'p':
50 iotrace_set_enabled(0);
51 break;
52 case 'r':
53 iotrace_set_enabled(1);
54 break;
55 case 's':
56 do_print_stats();
57 break;
58 default:
59 return CMD_RET_USAGE;
60 }
61
62 return 0;
63}
64
65U_BOOT_CMD(
66 iotrace, 4, 1, do_iotrace,
67 "iotrace utility commands",
68 "stats - display iotrace stats\n"
69 "iotrace buffer <address> <size> - set iotrace buffer\n"
70 "iotrace pause - pause tracing\n"
71 "iotrace resume - resume tracing"
72);