From patchwork Wed Oct 24 04:04:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 193658 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 301682C00F8 for ; Wed, 24 Oct 2012 15:06:35 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C29F34A49B; Wed, 24 Oct 2012 06:06:18 +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 WJDYHuHqlSHF; Wed, 24 Oct 2012 06:06:18 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 14AC34A4A0; Wed, 24 Oct 2012 06:05:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E2BC04A3D9 for ; Wed, 24 Oct 2012 06:05:15 +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 K57vozPoJjS9 for ; Wed, 24 Oct 2012 06:05:15 +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-bk0-f74.google.com (mail-bk0-f74.google.com [209.85.214.74]) by theia.denx.de (Postfix) with ESMTPS id 271FA4A419 for ; Wed, 24 Oct 2012 06:05:07 +0200 (CEST) Received: by mail-bk0-f74.google.com with SMTP id q16so5781bkw.3 for ; Tue, 23 Oct 2012 21:05:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=vwYwKyc42anfhKsjL+VR2hPSbHVS8xxcXAk2VzpXMGg=; b=VN5I2ATAdFOiTpNTbDXxtrVagW0y15rMYtZTEQQuyZf2JMVHW9i72C0QBb7NVHScCx JXBhpohZKJ/lcFRa9DSRPSi66eKByzmMQhU8sWNMegY3GMDXUW3ztMgkbfnyGwjpzlQE A/gOWU3VBqD7xc4vs8HsTeibWIP5sL04HIbIxQ08V1RdHUoJ6gitdlAib2NV4rwu3UWX hxYTHOp3zBf2b6fpDIxCtijLnQ4OXbHEtHYd0/rHkTRHSvG8EQqkg/OW7sMfOhAFbFdV a/QUemDNNTE/NSNZYO/rU+2IhFrrtouNEAfGGTIWr6Y1ECfxcvq0QAbygoXUQZtm+gqN PFUw== Received: by 10.180.87.100 with SMTP id w4mr233443wiz.3.1351051507287; Tue, 23 Oct 2012 21:05:07 -0700 (PDT) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id z7si105233wiw.1.2012.10.23.21.05.07 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 23 Oct 2012 21:05:07 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id DF504200057; Tue, 23 Oct 2012 21:05:06 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 51F6416162E; Tue, 23 Oct 2012 21:05:06 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 23 Oct 2012 21:04:45 -0700 Message-Id: <1351051486-6980-15-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1351051486-6980-1-git-send-email-sjg@chromium.org> References: <1351051486-6980-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQkj8Mwng7nG+JtaRDyjKOG2WuaDcB9akdjqdWGTX4o35Z8Ey/YAjza50GabJRTAUsppQ8MIYGTtdvRN4FDNtQGeuDWW86LMDoRjdDpzvDJsYAF4AIVuxFrKwVN6CvA+SsplvVUxT2twpNbZTPHqACaTE+5V1eaPLxCQGfASw8zsA5A/jm5zCxCzQP5J5g4moigBlMB/ Subject: [U-Boot] [PATCH 14/15] Introduce arch_phys_memset which works like memset but on physical memory 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 From: Gabe Black The default implementation of this function is just memset, but other implementations will be needed when physical memory isn't accessible by U-Boot using normal addressing mechanisms. Signed-off-by: Gabe Black Signed-off-by: Simon Glass --- include/physmem.h | 21 +++++++++++++++++++++ lib/physmem.c | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-) create mode 100644 include/physmem.h create mode 100644 lib/physmem.c diff --git a/include/physmem.h b/include/physmem.h new file mode 100644 index 0000000..03d3a78 --- /dev/null +++ b/include/physmem.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2012 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + */ + +/* + * These functions work like memset but operate on physical memory which may + * not be accessible directly. + * + * @param s The physical address to start setting memory at. + * @param c The character to set each byte of the region to. + * @param n The number of bytes to set. + * + * @return The physical address of the memory which was set. + */ +phys_addr_t arch_phys_memset(phys_addr_t s, int c, phys_size_t n); diff --git a/lib/physmem.c b/lib/physmem.c new file mode 100644 index 0000000..0f035ed --- /dev/null +++ b/lib/physmem.c @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + */ + +#include +#include + +static phys_addr_t __arch_phys_memset(phys_addr_t s, int c, phys_size_t n) +{ + void *s_ptr = (void *)(uintptr_t)s; + + assert(((phys_addr_t)(uintptr_t)s) == s); + assert(((phys_addr_t)(uintptr_t)(s + n)) == s + n); + return (phys_addr_t)(uintptr_t)memset(s_ptr, c, n); +} + +phys_addr_t arch_phys_memset(phys_addr_t s, int c, phys_size_t n) + __attribute__((weak, alias("__arch_phys_memset")));