From patchwork Wed Feb 20 16:58:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 222128 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 BB67E2C007B for ; Thu, 21 Feb 2013 03:59:18 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 321754A162; Wed, 20 Feb 2013 17:59:14 +0100 (CET) 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 Ha1WRYhqVQOr; Wed, 20 Feb 2013 17:59:13 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 753DB4A0EF; Wed, 20 Feb 2013 17:59:12 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 06C524A116 for ; Wed, 20 Feb 2013 17:59:10 +0100 (CET) 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 AD2t7xCE++M5 for ; Wed, 20 Feb 2013 17:59:08 +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 mail-vc0-f202.google.com (mail-vc0-f202.google.com [209.85.220.202]) by theia.denx.de (Postfix) with ESMTPS id 08B054A155 for ; Wed, 20 Feb 2013 17:59:04 +0100 (CET) Received: by mail-vc0-f202.google.com with SMTP id m8so814893vcd.1 for ; Wed, 20 Feb 2013 08:59:02 -0800 (PST) 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=zDWc43QNHfuN2kdcv6WWtTfor7mw8cFd6QlMudJc5Xg=; b=N4oBNY5/CNlBYoRmAdIAyVMTwKqEFVsDJKCWMT2UAwqKSeaRfrx6BH4l++bI4dZLo9 qGJ2Ood2TTqeOoFii4o51DOT0HZvA+NGvhJ7fl2GBwX4ycOnny1T9IPOtLafzM9gG9hg lxY+f0zvtFntb3DCx0zJQj+iR6G42LtAnlJ0LjLiDQUE9OeE/0KVSug3VvtHqU4NMjzF QmHUX0KeenS7Ur8qXtl2wQ6V0mmJRImOEWjM0s7jJKEdmqTSTGo69i38evGy50EvHzgv KV/N+CnhOs2hswnBqUK4BmFAGT3Y9AYL6wDlJ7G4SwRRXWA8AZ6m+0kBN+wN/xEFCWu0 jimg== X-Received: by 10.236.126.5 with SMTP id a5mr10454638yhi.34.1361379542026; Wed, 20 Feb 2013 08:59:02 -0800 (PST) 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 f64si4024150yhj.7.2013.02.20.08.59.02 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Wed, 20 Feb 2013 08:59:02 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id DC50C5A42AA; Wed, 20 Feb 2013 08:59:01 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 9D6FD160720; Wed, 20 Feb 2013 08:59:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Wed, 20 Feb 2013 08:58:35 -0800 Message-Id: <1361379515-23802-22-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1361379515-23802-17-git-send-email-sjg@chromium.org> References: <1361379515-23802-17-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQkwMTN/Bc/Ybe9B1sSctu4C66mmGkxZJB/wNf0qdOTsKR30VG4YkPd4QCE3x2nHWI7whWY7dw0hR2pFX1eQih6IVhZRjgAXUJXHrAXIfL/optxAEbZ/E9uVzPkceUSPnfguojteSwkWiCawdYlTLmmW+0IpRTEMQKikSjNYP4w9GSKzJSwUOGHSzt2gSB1UJ2ibClex Cc: Tom Rini Subject: [U-Boot] [PATCH v2 21/21] sandbox: Allow hash functions to work correctly 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 Use map_sysmem() so that hashing is possible on sandbox. Signed-off-by: Simon Glass --- Changes in v2: - Rebase on top of earlier patches common/hash.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/common/hash.c b/common/hash.c index 984cbe4..1c33ef7 100644 --- a/common/hash.c +++ b/common/hash.c @@ -28,6 +28,7 @@ #include #include #include +#include /* * These are the hash algorithms we support. Chips which support accelerated @@ -112,10 +113,13 @@ static void store_result(struct hash_algo *algo, const u8 *sum, str_ptr = '\0'; setenv(dest, str_output); } else { - u8 *ptr; + ulong addr; + void *buf; - ptr = (u8 *)simple_strtoul(dest, NULL, 16); - memcpy(ptr, sum, algo->digest_size); + addr = simple_strtoul(dest, NULL, 16); + buf = map_sysmem(addr, algo->digest_size); + memcpy(buf, sum, algo->digest_size); + unmap_sysmem(buf); } } @@ -149,10 +153,12 @@ static int parse_verify_sum(struct hash_algo *algo, char *verify_str, u8 *vsum, } if (env_var) { - u8 *ptr; + ulong addr; + void *buf; - ptr = (u8 *)simple_strtoul(verify_str, NULL, 16); - memcpy(vsum, ptr, algo->digest_size); + addr = simple_strtoul(verify_str, NULL, 16); + buf = map_sysmem(addr, algo->digest_size); + memcpy(vsum, buf, algo->digest_size); } else { unsigned int i; char *vsum_str; @@ -223,6 +229,7 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag, struct hash_algo *algo; u8 output[HASH_MAX_DIGEST_SIZE]; u8 vsum[HASH_MAX_DIGEST_SIZE]; + void *buf; algo = find_hash_algo(algo_name); if (!algo) { @@ -236,8 +243,9 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag, return 1; } - algo->hash_func_ws((const unsigned char *)addr, len, output, - algo->chunk_size); + buf = map_sysmem(addr, len); + algo->hash_func_ws(buf, len, output, algo->chunk_size); + unmap_sysmem(buf); /* Try to avoid code bloat when verify is not needed */ #ifdef CONFIG_HASH_VERIFY