]> git.ipfire.org Git - thirdparty/u-boot.git/blame - cmd/conitrace.c
efi_loader: replace find_smbios_table by library function
[thirdparty/u-boot.git] / cmd / conitrace.c
CommitLineData
29cfc096
HS
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * The 'conitrace' command prints the codes received from the console input as
4 * hexadecimal numbers.
5 *
6 * Copyright (c) 2018, Heinrich Schuchardt <xypron.glpk@gmx.de>
7 */
8#include <common.h>
9#include <command.h>
c05ed00a 10#include <linux/delay.h>
29cfc096 11
09140113
SG
12static int do_conitrace(struct cmd_tbl *cmdtp, int flag, int argc,
13 char *const argv[])
29cfc096
HS
14{
15 bool first = true;
16
17 printf("Waiting for your input\n");
18 printf("To terminate type 'x'\n");
19
20 /* Empty input buffer */
21 while (tstc())
2fb3ed2c 22 getchar();
29cfc096
HS
23
24 for (;;) {
2fb3ed2c 25 int c = getchar();
29cfc096
HS
26
27 if (first && (c == 'x' || c == 'X'))
28 break;
29
30 printf("%02x ", c);
31 first = false;
32
48618e9b
HS
33 /* 10 ms delay - serves to detect separate keystrokes */
34 udelay(10000);
29cfc096
HS
35 if (!tstc()) {
36 printf("\n");
37 first = true;
38 }
39 }
40
41 return CMD_RET_SUCCESS;
42}
43
3616218b 44U_BOOT_LONGHELP(conitrace, "");
29cfc096
HS
45
46U_BOOT_CMD_COMPLETE(
47 conitrace, 2, 0, do_conitrace,
48 "trace console input",
49 conitrace_help_text, NULL
50);