From patchwork Wed Oct 3 22:14:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 188942 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 25D602C0320 for ; Thu, 4 Oct 2012 08:15:41 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B0B28281A1; Thu, 4 Oct 2012 00:15:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wz3wMS4-WahB; Thu, 4 Oct 2012 00:15:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1687928194; Thu, 4 Oct 2012 00:15:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1F7B828194 for ; Thu, 4 Oct 2012 00:15:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LMFwaylOEyY8 for ; Thu, 4 Oct 2012 00:15:32 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from spamkiller06.natinst.com (mailserver6.natinst.com [130.164.80.6]) by theia.denx.de (Postfix) with ESMTP id 1CFD028193 for ; Thu, 4 Oct 2012 00:15:30 +0200 (CEST) Received: from mailserv58-us.natinst.com (nb-hsrp-1338.natinst.com [130.164.19.133]) by spamkiller06.natinst.com (8.14.4/8.14.4) with ESMTP id q93MFONl004878; Wed, 3 Oct 2012 17:15:24 -0500 Received: from linux-xvxi.natinst.com ([130.164.14.197]) by mailserv58-us.natinst.com (Lotus Domino Release 8.5.3FP2 HF169) with ESMTP id 2012100317152432-382487 ; Wed, 3 Oct 2012 17:15:24 -0500 From: Joe Hershberger To: u-boot@lists.denx.de Date: Wed, 3 Oct 2012 17:14:57 -0500 Message-Id: <1349302497-15457-1-git-send-email-joe.hershberger@ni.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <1345237078-20413-1-git-send-email-joe.hershberger@ni.com> References: <1345237078-20413-1-git-send-email-joe.hershberger@ni.com> X-MIMETrack: Itemize by SMTP Server on MailServ58-US/AUS/H/NIC(Release 8.5.3FP2 HF169|September 14, 2012) at 10/03/2012 05:15:24 PM, Serialize by Router on MailServ58-US/AUS/H/NIC(Release 8.5.3FP2 HF169|September 14, 2012) at 10/03/2012 05:15:24 PM, Serialize complete at 10/03/2012 05:15:24 PM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.7.7855, 1.0.431, 0.0.0000 definitions=2012-10-03_02:2012-10-03, 2012-10-03, 1970-01-01 signatures=0 Cc: Tom Rini , Joe Hershberger Subject: [U-Boot] [PATCH v2] Add a command to access the system timer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Two sub-commands... start and get. * start sets the reference. * get prints out the time since the last start (in "." format). If get is called without start, returns time since boot. Simple way to benchmark an operation: "timer start;;timer get" Signed-off-by: Joe Hershberger --- Changes in v2: - Added config guard around the command - Documented in README - Documented CONFIG_CMD_TIME as being ARM specific - Style fix ',' - Made function static README | 3 ++- common/cmd_misc.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README b/README index af76b0c..8305e45 100644 --- a/README +++ b/README @@ -855,7 +855,8 @@ The following options need to be configured: CONFIG_CMD_SPI * SPI serial bus support CONFIG_CMD_TFTPSRV * TFTP transfer in server mode CONFIG_CMD_TFTPPUT * TFTP put command (upload) - CONFIG_CMD_TIME * run command and report execution time + CONFIG_CMD_TIME * run command and report execution time (ARM specific) + CONFIG_CMD_TIMER * access to the system tick timer CONFIG_CMD_USB * USB support CONFIG_CMD_CDP * Cisco Discover Protocol support CONFIG_CMD_MFSL * Microblaze FSL support diff --git a/common/cmd_misc.c b/common/cmd_misc.c index 973b1c2..3b47a0c 100644 --- a/common/cmd_misc.c +++ b/common/cmd_misc.c @@ -53,3 +53,30 @@ U_BOOT_CMD( "N\n" " - delay execution for N seconds (N is _decimal_ !!!)" ); + +#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\n", msecs / 1000, (int)(msecs % 1000)); + } + + return 0; +} + +U_BOOT_CMD( + timer, 2, 1, do_timer, + "access the system timer", + "start - Reset the timer reference.\n" + "timer get - Print the time since 'start'." +); +#endif