From patchwork Sat Apr 20 18:42:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 238159 X-Patchwork-Delegate: sjg@chromium.org 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 35E262C014C for ; Sun, 21 Apr 2013 04:44:19 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B5A624A3C9; Sat, 20 Apr 2013 20:44:08 +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 nBkBDLsve5Ro; Sat, 20 Apr 2013 20:44:08 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7A51D4A3C6; Sat, 20 Apr 2013 20:43:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4FEF84A365 for ; Sat, 20 Apr 2013 20:43:34 +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 Ar9wS1msdMwM for ; Sat, 20 Apr 2013 20:43:33 +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 mail-gg0-f201.google.com (mail-gg0-f201.google.com [209.85.161.201]) by theia.denx.de (Postfix) with ESMTPS id 0F3E74A3AA for ; Sat, 20 Apr 2013 20:43:19 +0200 (CEST) Received: by mail-gg0-f201.google.com with SMTP id q6so545518ggc.4 for ; Sat, 20 Apr 2013 11:43:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=n4c42J9t5w1SfU/Rg/n/S5QRNBP14tm4smOe5uU0z+0=; b=SCunjJSCtO0Q4KednJ1n+hGyHijElVaA1OFDQkc6QC1vfLFXhmSQ9vYGezI9SJf63n kVjYchfSjcQOD3rd/ppKHcSRykurC1YIuSh9sUuQR9ix80s0TUVpLxfuOrCpFdcbuihY 6OEPH0n2PxjMq7swEWnl+00njrUISvaJE+mVu++ixOcGziZdl69n/j0//NOpc84W3atU IFjVIBqwMOGPkGxMpQsuthlncapUTCLZ0hmQCLTjycxY6RpwFCeZNaI8MHX2NDPJNCI4 GBmadHVvuuvCmE6BZ2F7u8h0VrLQj+5AZBqp1MUDBQw7Wi+d9C8BWX04wMbel2b3myhJ MJ9Q== X-Received: by 10.236.41.137 with SMTP id h9mr4846294yhb.43.1366483396130; Sat, 20 Apr 2013 11:43:16 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id u58si4434887yhe.2.2013.04.20.11.43.16 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Sat, 20 Apr 2013 11:43:16 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id EA2835A416A; Sat, 20 Apr 2013 11:43:15 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id CBA4516068E; Sat, 20 Apr 2013 11:43:15 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 20 Apr 2013 11:42:49 -0700 Message-Id: <1366483372-16523-15-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1366483372-16523-1-git-send-email-sjg@chromium.org> References: <1366483372-16523-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQnr/I5grPCaBS3FkP2aV20+lzf/9tzmLn+upaw7o9uX2F37kkY2qqdLEZBRkv0xoABIn98yST2irJ8BNas4cK0EPb/E4/8HZtXJliHp5haZCaY0GxcCvsHXbF5Gtn8uix9u38/9KrgMDF6/BWTn/ooe3Xh20DYw5j3t+oza961/Vx1spTn29XyuJA0QqyANnLB+ASAG Cc: Tom Rini , u-boot-review@google.com Subject: [U-Boot] [PATCH v3 14/17] sandbox: Support 'source' command 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 Enhance the source command to work with sandbox, by using map_sysmem() to convert a ulong address into a pointer. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/cmd_source.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/cmd_source.c b/common/cmd_source.c index 02a862c..f0d7f52 100644 --- a/common/cmd_source.c +++ b/common/cmd_source.c @@ -36,6 +36,7 @@ #include #include #include +#include #if defined(CONFIG_8xx) #include #endif @@ -44,9 +45,10 @@ int source (ulong addr, const char *fit_uname) { ulong len; - image_header_t *hdr; + const image_header_t *hdr; ulong *data; int verify; + void *buf; #if defined(CONFIG_FIT) const void* fit_hdr; int noffset; @@ -56,9 +58,10 @@ source (ulong addr, const char *fit_uname) verify = getenv_yesno ("verify"); - switch (genimg_get_format ((void *)addr)) { + buf = map_sysmem(addr, 0); + switch (genimg_get_format(buf)) { case IMAGE_FORMAT_LEGACY: - hdr = (image_header_t *)addr; + hdr = buf; if (!image_check_magic (hdr)) { puts ("Bad magic number\n"); @@ -104,7 +107,7 @@ source (ulong addr, const char *fit_uname) return 1; } - fit_hdr = (const void *)addr; + fit_hdr = buf; if (!fit_check_format (fit_hdr)) { puts ("Bad FIT image format\n"); return 1;