From patchwork Tue Nov 10 12:13:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jacquiot.aurelien@gmail.com X-Patchwork-Id: 56299 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp762346lbb; Tue, 10 Nov 2015 05:13:12 -0800 (PST) X-Received: by 10.28.17.71 with SMTP id 68mr4371439wmr.59.1447161192275; Tue, 10 Nov 2015 05:13:12 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id pu5si4386285wjc.50.2015.11.10.05.13.12; Tue, 10 Nov 2015 05:13:12 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B32584B8EB; Tue, 10 Nov 2015 14:13:10 +0100 (CET) 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 44ovEsdGfV9G; Tue, 10 Nov 2015 14:13:10 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EBF924B8ED; Tue, 10 Nov 2015 14:12:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1FD6F4B8BC for ; Tue, 10 Nov 2015 13:13:26 +0100 (CET) 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 PUoSqz56Thdk for ; Tue, 10 Nov 2015 13:13:26 +0100 (CET) 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 arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by theia.denx.de (Postfix) with ESMTPS id 9B2484B8B9 for ; Tue, 10 Nov 2015 13:13:20 +0100 (CET) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id tAACDIxQ011441; Tue, 10 Nov 2015 06:13:18 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id tAACDI2X007943; Tue, 10 Nov 2015 06:13:18 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.224.2; Tue, 10 Nov 2015 06:13:18 -0600 Received: from svrmail.tif.ti.com (svrmail.tif.ti.com [137.167.140.111]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id tAACDHvm015059; Tue, 10 Nov 2015 06:13:17 -0600 Received: from vmuna0919873.tif.ti.com (vmuna0919873.tif.ti.com [137.167.140.82]) by svrmail.tif.ti.com (Postfix) with ESMTP id 3B2CF27DFCF; Tue, 10 Nov 2015 13:13:17 +0100 (CET) Received: (from a0919873@localhost) by vmuna0919873.tif.ti.com (8.14.4/8.14.4/Submit) id tAACDHis003677; Tue, 10 Nov 2015 13:13:17 +0100 From: To: Date: Tue, 10 Nov 2015 13:13:17 +0100 Message-ID: <1447157597-3645-1-git-send-email-jacquiot.aurelien@gmail.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 10 Nov 2015 14:10:53 +0100 Cc: trini@konsulko.com Subject: [U-Boot] [PATCH 1/4] cmd_mem.c: add a memory wait (mwait) command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Aurelien Jacquiot This new memory command allows to wait a given value in memory. It can be useful when U-Boot is used in a slave mode (another device is pushing images to the local memory) such as RapidIO or any RDMA kind of transport. We can then be notified that images have been loaded to our memory before booting. Usage is: mwait[.b, .w, .l, .q] address value Signed-off-by: Aurelien Jacquiot --- common/cmd_mem.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 69 insertions(+), 0 deletions(-) -- 1.6.2.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 43c3fb6..af6e39d 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -1238,6 +1238,65 @@ static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #endif +static int +do_mem_mwait(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + ulong addr; +#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA + u64 val, readval; +#else + ulong val, readval; +#endif + int size; + + if (argc != 3) + return CMD_RET_USAGE; + + /* check for size specification */ + size = cmd_get_data_size(argv[0], 4); + if (size < 1) + return 1; + + /* first arg: address */ + addr = simple_strtoul(argv[1], NULL, 16); + + /* second arg: expected value */ +#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA + val = simple_strtoull(argv[2], NULL, 16); + printf("waiting 0x%llx at 0x%lx...\n", val, addr); +#else + val = simple_strtoul(argv[2], NULL, 16); + printf("waiting 0x%lx at 0x%lx...\n", val, addr); +#endif + + for (;;) { + if (size == 4) + readval = *((u32 *)addr); +#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA + else if (size == 8) + readval = *((u64 *)addr); +#endif + else if (size == 2) + readval = *((u16 *)addr); + else + readval = *((u8 *)addr); + + if (readval == val) + return 0; + + /* check for ctrl-c to abort... */ + if (ctrlc()) { + puts("Abort\n"); + return 0; + } + + WATCHDOG_RESET(); + udelay(1000); + } + + return 0; +} + /**************************************************/ U_BOOT_CMD( md, 3, 1, do_mem_md, @@ -1399,6 +1458,16 @@ U_BOOT_CMD( ); #endif /* CONFIG_MX_CYCLIC */ +U_BOOT_CMD( + mwait, 3, 1, do_mem_mwait, + "memory wait for value", +#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA + "[.b, .w, .l, .q] address value\n" +#else + "[.b, .w, .l] address value\n" +#endif +); + #ifdef CONFIG_CMD_MEMINFO U_BOOT_CMD( meminfo, 3, 1, do_mem_info,