From patchwork Wed Jun 4 03:01:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Wu X-Patchwork-Id: 355707 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 E39291400DE for ; Wed, 4 Jun 2014 13:11:14 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EA9054B963; Wed, 4 Jun 2014 05:11:12 +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 Y1Tx5Eiu31-i; Wed, 4 Jun 2014 05:11:12 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7E2CA4B965; Wed, 4 Jun 2014 05:11:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5C8AE4B965 for ; Wed, 4 Jun 2014 05:11:03 +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 QB3OmlLiJgOE for ; Wed, 4 Jun 2014 05:10:56 +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 DVREDG02.corp.atmel.com (nasmtp01.atmel.com [192.199.1.246]) by theia.denx.de (Postfix) with ESMTPS id 714BF4B963 for ; Wed, 4 Jun 2014 05:10:51 +0200 (CEST) Received: from apsmtp01.atmel.com (10.168.254.31) by DVREDG02.corp.atmel.com (10.42.103.31) with Microsoft SMTP Server (TLS) id 14.2.347.0; Tue, 3 Jun 2014 21:10:37 -0600 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.atmel.com (10.168.254.31) with Microsoft SMTP Server id 14.2.347.0; Wed, 4 Jun 2014 11:12:17 +0800 From: Josh Wu To: Date: Wed, 4 Jun 2014 11:01:24 +0800 Message-ID: <1401850884-4265-1-git-send-email-josh.wu@atmel.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Subject: [U-Boot] [PATCH v2] fs: fatwrite: use map_sysmem before use file_fat_write 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de When the map_sysmem, then the fatwrite command can support sandbox. Following command will show how to use it: => sb bind 0 sd.img => fatls host 0 => fatwrite host 0 $memaddr filename $filesize Signed-off-by: Josh Wu Acked-by: Simon Glass --- v1 -> v2: remove the type cast for the addr. common/cmd_fat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/cmd_fat.c b/common/cmd_fat.c index a12d8fa..fbe3346 100644 --- a/common/cmd_fat.c +++ b/common/cmd_fat.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -93,6 +94,7 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, disk_partition_t info; int dev = 0; int part = 1; + void *buf; if (argc < 5) return cmd_usage(cmdtp); @@ -111,7 +113,9 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, addr = simple_strtoul(argv[3], NULL, 16); count = simple_strtoul(argv[5], NULL, 16); - size = file_fat_write(argv[4], (void *)addr, count); + buf = map_sysmem(addr, count); + size = file_fat_write(argv[4], buf, count); + unmap_sysmem(buf); if (size == -1) { printf("\n** Unable to write \"%s\" from %s %d:%d **\n", argv[4], argv[1], dev, part);