Blame view
common/cmd_misc.c
1.21 KB
3863585bb Initial revision |
1 2 3 4 |
/* * (C) Copyright 2001 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * |
1a4596601 Add GPL-2.0+ SPDX... |
5 |
* SPDX-License-Identifier: GPL-2.0+ |
3863585bb Initial revision |
6 7 8 9 10 11 12 |
*/ /* * Misc functions */ #include <common.h> #include <command.h> |
088f1b199 common/cmd_*.c: s... |
13 |
static int do_sleep(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
14 |
{ |
c4c13df28 Fix problem with ... |
15 |
ulong start = get_timer(0); |
3863585bb Initial revision |
16 |
ulong delay; |
47e26b1bf cmd_usage(): simp... |
17 |
if (argc != 2) |
4c12eeb8b Convert cmd_usage... |
18 |
return CMD_RET_USAGE; |
3863585bb Initial revision |
19 |
|
6d0f6bcf3 rename CFG_ macro... |
20 |
delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ; |
3863585bb Initial revision |
21 |
|
c4c13df28 Fix problem with ... |
22 |
while (get_timer(start) < delay) { |
088f1b199 common/cmd_*.c: s... |
23 |
if (ctrlc()) |
c4c13df28 Fix problem with ... |
24 |
return (-1); |
47e26b1bf cmd_usage(): simp... |
25 |
|
088f1b199 common/cmd_*.c: s... |
26 |
udelay(100); |
3863585bb Initial revision |
27 |
} |
c4c13df28 Fix problem with ... |
28 |
|
3863585bb Initial revision |
29 30 |
return 0; } |
c4c13df28 Fix problem with ... |
31 |
|
0d4983930 Patch by Kenneth ... |
32 |
U_BOOT_CMD( |
9912121f7 Change 'repeatabl... |
33 |
sleep , 2, 1, do_sleep, |
2fb2604d5 Command usage cle... |
34 |
"delay execution for some time", |
8bde7f776 * Code cleanup: |
35 36 |
"N " |
a89c33db9 General help mess... |
37 |
" - delay execution for N seconds (N is _decimal_ !!!)" |
8bde7f776 * Code cleanup: |
38 |
); |
da83bcd7b Add a command to ... |
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
#ifdef CONFIG_CMD_TIMER static int do_timer(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { static ulong start; if (argc != 2) return CMD_RET_USAGE; if (!strcmp(argv[1], "start")) start = get_timer(0); if (!strcmp(argv[1], "get")) { ulong msecs = get_timer(start) * 1000 / CONFIG_SYS_HZ; printf("%ld.%03d ", msecs / 1000, (int)(msecs % 1000)); } return 0; } U_BOOT_CMD( timer, 2, 1, do_timer, "access the system timer", "start - Reset the timer reference. " "timer get - Print the time since 'start'." ); #endif |