From patchwork Mon Feb 25 03:33:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 222834 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 50CB52C0080 for ; Mon, 25 Feb 2013 14:36:50 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9F65B4A357; Mon, 25 Feb 2013 04:36:08 +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 zZHhn5H2GKmj; Mon, 25 Feb 2013 04:36:08 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9CD464A188; Mon, 25 Feb 2013 04:34:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 331B14A12D for ; Mon, 25 Feb 2013 04:34: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 ZDpnfCRfKnfk for ; Mon, 25 Feb 2013 04:34:09 +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-f201.google.com (mail-vc0-f201.google.com [209.85.220.201]) by theia.denx.de (Postfix) with ESMTPS id 3E67F4A122 for ; Mon, 25 Feb 2013 04:33:56 +0100 (CET) Received: by mail-vc0-f201.google.com with SMTP id n11so254522vch.2 for ; Sun, 24 Feb 2013 19:33:55 -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=IGcnwXLK8N5X2nHDndsR0bQF2fVE7sQW5GpMlGrAOM4=; b=NIR5uTF/eQV3BLyQBk7K+c2ymTLU0RrPYUfmONnlDE+8bmuDsNJ3QzxUlkQ4w2swBh kW9NyltFy2sXGHTRzxJMz+1r4kQbI2KnJinoGUIPeb+TktnPSbyVAvjgXvTk9cz/ubaW SB3JlVDmsFOaykaf8c2ZQLbIEBNQnsho2ucD65uRrW6rZVj1KuvfLdKy2HKzyoKzM46p Yt34QiOnBcslIEjbNKobueUDCjFLz6ptGBB8xy+ccL91sYiNT6Mm65xFpoAH8Y4jvPQS BkmcUbAsBr8Aaf3M0118TaWjTNW+Xre5Wroj8LXteVglL1bnuCtorQPp40IcGsjG0M4O drfA== X-Received: by 10.236.171.103 with SMTP id q67mr5687706yhl.35.1361763235808; Sun, 24 Feb 2013 19:33:55 -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 e21si409923anp.1.2013.02.24.19.33.55 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Sun, 24 Feb 2013 19:33:55 -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 A516C5A4102; Sun, 24 Feb 2013 19:33:55 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 86C69160537; Sun, 24 Feb 2013 19:33:55 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Sun, 24 Feb 2013 19:33:31 -0800 Message-Id: <1361763213-31183-22-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1361763213-31183-1-git-send-email-sjg@chromium.org> References: <1361763213-31183-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmVdCibWjbm7BIm/ZLqU3MlBc0Jdc1lgpJksVdplvy9vcTNbPkJv9eH9Xf4SyiOlTdikgeNszchjQjJyeSqRgbjk1Ad+WOPpz+/fGowgU73JXhQks/22Ye4c3xH/XZItEjE66aV0WJ9oQdWs3zEAy7sPlFZiTPkYFrfqYShXp1CTx6mdXgYD8Q7eKEFxGl3BchgH/k3 Cc: Tom Rini Subject: [U-Boot] [PATCH v3 21/22] 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 v3: None 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 2617316..d6f4aa1 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 @@ -117,10 +118,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); } } @@ -154,10 +158,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; @@ -228,6 +234,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) { @@ -241,8 +248,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