From patchwork Sun Dec 2 14:55:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 203229 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 ED4162C0092 for ; Mon, 3 Dec 2012 01:55:56 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A04A54A058; Sun, 2 Dec 2012 15:55:55 +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 CBnc0cgcR6Ca; Sun, 2 Dec 2012 15:55:55 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F04284A037; Sun, 2 Dec 2012 15:55:53 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4489C4A053 for ; Sun, 2 Dec 2012 15:55:51 +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 SZa9m+80Cf4U for ; Sun, 2 Dec 2012 15:55:49 +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-qa0-f74.google.com (mail-qa0-f74.google.com [209.85.216.74]) by theia.denx.de (Postfix) with ESMTPS id 1AE3E4A037 for ; Sun, 2 Dec 2012 15:55:38 +0100 (CET) Received: by mail-qa0-f74.google.com with SMTP id r4so183790qaq.3 for ; Sun, 02 Dec 2012 06:55:37 -0800 (PST) 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=ctHJQ16mV7LLGzoU8pVtTlpwdPnpZ7G/Cu57h/gojQ4=; b=Ztmff0RGoT3e3imW3gkl7b01ok9kzsIFiBa5zOASEFfB/UC/1knHWgNGEvHUrX3I6D ZRW+m3Dq0zqsjg2zNKk1wxh0NR2mBIXyqTOCnzMPJ70him/64W87pWAKz9iuYSniAPMK KG1BmWXrWBiPnBcjiVl6/yoIkni7hp1o0tLt4HgyLG5TyuOh4fyfH6z4jjk7s74w+bC2 R4xC+TjX3yYG/NEHeCfv0SmzJPMAMWWFXYcaE97JHXig6MsmqokFkMXfCHzyRdXz+VO3 zE4awcVZpBEtSGuegDJ12xRxZKS4/UWQQg0L386IeJWnQPZqbTtOkWKkbvyKvPvnZIjE egPw== Received: by 10.236.83.235 with SMTP id q71mr4833392yhe.5.1354460137805; Sun, 02 Dec 2012 06:55:37 -0800 (PST) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id i63si685724yhk.5.2012.12.02.06.55.37 (version=TLSv1/SSLv3 cipher=AES128-SHA); Sun, 02 Dec 2012 06:55:37 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 8DFBF82004A; Sun, 2 Dec 2012 06:55:37 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 4C96F1610BE; Sun, 2 Dec 2012 06:55:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Sun, 2 Dec 2012 06:55:18 -0800 Message-Id: <1354460119-23877-15-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1354460119-23877-8-git-send-email-sjg@chromium.org> References: <1354460119-23877-8-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQniIGQs67sPd3CTKtUfC96Cw/EoT1nXcNvq1ySAi3uc2jL7RAhu9U35SrXVxPS/n8dJU22ieoInKPlqnFGyeidPA1OyZO6h5jvLrEepC8k5H0HnRynh1qPq3A9DUyzXkTWIXCmH7QKD1M9RAJeBLpuM+9GefGhVdc1gfSCZszA9/10ObbbnPsloifaCs25SIum0dmPP Cc: Tom Rini Subject: [U-Boot] [PATCH v2 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: Che-Liang Chiou Signed-off-by: Simon Glass --- Changes in v2: - Update README and add to Makefile README | 8 ++++++++ include/physmem.h | 21 +++++++++++++++++++++ lib/Makefile | 1 + lib/physmem.c | 24 ++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 0 deletions(-) create mode 100644 include/physmem.h create mode 100644 lib/physmem.c diff --git a/README b/README index ed7d270..c7aab18 100644 --- a/README +++ b/README @@ -2200,6 +2200,14 @@ CBFS (Coreboot Filesystem) support HERMES, IP860, RPXlite, LWMON, FLAGADM, TQM8260 +- Access to physical memory region (> 4GB) + Some basic support is provided for operations on memory not + normally accessible to U-Boot - e.g. some architectures + support access to more than 4GB of memory on 32-bit + machines using physical address extension or similar. + Define CONFIG_PHYSMEM to access this basic support, which + currently only supports clearing the memory. + - Error Recovery: CONFIG_PANIC_HANG 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/Makefile b/lib/Makefile index e44e045..f83f6e8 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -48,6 +48,7 @@ COBJS-$(CONFIG_LMB) += lmb.o COBJS-y += ldiv.o COBJS-$(CONFIG_MD5) += md5.o COBJS-y += net_utils.o +COBJS-$(CONFIG_PHYSMEM) += physmem.o COBJS-y += qsort.o COBJS-$(CONFIG_SHA1) += sha1.o COBJS-$(CONFIG_SHA256) += sha256.o 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")));