summaryrefslogtreecommitdiffstats
path: root/qemu/roms/u-boot/common/cmd_gettime.c
blob: 320ff709fafba3a6abe2f5f1cb6b12a152788df1 (plain)
1
2
3
4
5
6
7
8
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.O
/*
 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
 *
 * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
 *
 * (C) Copyright 2001
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */

/*
 * Get Timer overflows after 2^32 / CONFIG_SYS_HZ (32Khz) = 131072 sec
 */
#include <common.h>
#include <command.h>

static int do_gettime(cmd_tbl_t *cmdtp, int flag, int argc,
		      char * const argv[])
{
	unsigned long int val = get_timer(0);

#ifdef CONFIG_SYS_HZ
	printf("Timer val: %lu\n", val);
	printf("Seconds : %lu\n", val / CONFIG_SYS_HZ);
	printf("Remainder : %lu\n", val % CONFIG_SYS_HZ);
	printf("sys_hz = %lu\n", (unsigned long int)CONFIG_SYS_HZ);
#else
	printf("CONFIG_SYS_HZ not defined");
	printf("Timer Val %lu", val);
#endif

	return 0;
}

U_BOOT_CMD(
	gettime,	1,	1,	do_gettime,
	"get timer val elapsed,\n",
	"get time elapsed from uboot start\n"
);