From patchwork Wed Dec 26 18:56:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 208198 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 D379B2C00BD for ; Thu, 27 Dec 2012 06:00:46 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AA4074A14F; Wed, 26 Dec 2012 20:00:43 +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 rRzPRvh84WuW; Wed, 26 Dec 2012 20:00:43 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1B2924A10C; Wed, 26 Dec 2012 19:58:49 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 548B34A052 for ; Wed, 26 Dec 2012 19:57:57 +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 d4vp0Xv4WAoZ for ; Wed, 26 Dec 2012 19:57:55 +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-la0-f73.google.com (mail-la0-f73.google.com [209.85.215.73]) by theia.denx.de (Postfix) with ESMTPS id B67CA4A0AB for ; Wed, 26 Dec 2012 19:57:36 +0100 (CET) Received: by mail-la0-f73.google.com with SMTP id d3so503758lah.0 for ; Wed, 26 Dec 2012 10:57:31 -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=CVG/gjVdNRk77BPOgRPR94YXNeU1XQXiXyGZTlfaLQ0=; b=K3vkVqTOArZ6uFH0dX/W2Erkj6r9pDCQ7LR/IwPALo+qMQ+1gqpzVeNQk66+ccfQ4A hfQsZ9IFDG/o9bZgPZIpB1sWkDfLJrB3XhChVauDqKfP/GMVt50tT9o8oiKaqo0bnQGo FraL1tNMLfwWuUBQkwoQMxqKX4eM8cO1mEGNvHiPtNMWArNfbm8XNTB6UJUaNjWJlhjl +XDMJRdxSwYwpsu0sBXv1YeyBWzimckXToO3kNnlsgrCqNyxKgiYNOwIvWGywp/WwLV/ dJOR2iW6duAkIRWUODNXQeDj36CQKX/qlYNh332jUO6hNTcDgMEvILlcgBaxO683v0Hw gcYg== X-Received: by 10.14.224.201 with SMTP id x49mr35905068eep.5.1356548251686; Wed, 26 Dec 2012 10:57:31 -0800 (PST) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id g9si10338381eeo.1.2012.12.26.10.57.31 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 26 Dec 2012 10:57:31 -0800 (PST) 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 1858720005C; Wed, 26 Dec 2012 10:57:31 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 74960160DA6; Wed, 26 Dec 2012 10:57:30 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Wed, 26 Dec 2012 10:56:57 -0800 Message-Id: <1356548233-5570-5-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1356548233-5570-1-git-send-email-sjg@chromium.org> References: <1356548233-5570-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQnnGXJRnkDG4MLqO7cD2gr0RYArD7FeMGln/PwdLcTOYbRdiLGV0QF9cyvOTUfV+nt2JZbu8KgJD1beZczkajjkCAyQKlD0uBj+4Go4MfNLVW4RXX/MDLwFOpR77o4wEGFsDGVwdO7mwRVnSCqKxgtqF+3W3SlVPiLT3zCVV4d+j/ndc96Tr27VmxuDm3acXRKurK11 Cc: Tom Rini , Joe Hershberger , Kumar Gala Subject: [U-Boot] [PATCH 04/20] sandbox: Add un/map_sysmen() to deal with sandbox's ram_buf 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 Sandbox doesn't actually provide U-Boot access to the machine's physical memory. Instead it provides a RAM buffer of configurable size, and all memory accesses are within that buffer. Sandbox memory starts at 0 and is CONFIG_DRAM_SIZE bytes in size. Allowing access outside this buffer might produce unpredictable results in the event of an error, and would expose the host machine's memory architecture to the sandbox U-Boot. Most U-Boot functions assume that they can just access memory at given address. For sandbox this is not true. Add a map_sysmem() call which converts a U-Boot address to a system address. In most cases this is a NOP, but for sandbox it returns a pointer to that memory inside the RAM buffer. To get a U-Boot feature to work correctly within sandbox, you should call map_sysmem() to get a pointer to the address, and then use that address for any U-Boot memory accesses. Signed-off-by: Simon Glass --- README | 9 +++++++++ arch/sandbox/config.mk | 1 + arch/sandbox/include/asm/io.h | 10 ++++++++++ include/common.h | 12 ++++++++++++ 4 files changed, 32 insertions(+), 0 deletions(-) diff --git a/README b/README index 78f40df..8dd3867 100644 --- a/README +++ b/README @@ -3769,6 +3769,15 @@ Low Level (hardware related) configuration options: that is executed before the actual U-Boot. E.g. when compiling a NAND SPL. +- CONFIG_ARCH_MAP_SYSMEM + Generally U-Boot (and in particular the md command) uses + effective address. It is therefore not necessary to regard + U-Boot address as virtual addresses that need to be translated + to physical addresses. However, sandbox requires this, since + it maintains its own little RAM buffer which contains all + addressable memory. This option causes some memory accesses + to be mapped through map_sysmem() / unmap_sysmem(). + - CONFIG_USE_ARCH_MEMCPY CONFIG_USE_ARCH_MEMSET If these options are used a optimized version of memcpy/memset will diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 02ce4a4..4fd0d4e 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -18,4 +18,5 @@ # MA 02111-1307 USA PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__ -U_FORTIFY_SOURCE +PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM PLATFORM_LIBS += -lrt diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index 0392d21..d8c0236 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -39,3 +39,13 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags) { } + +/* For sandbox, we want addresses to point into our RAM buffer */ +static inline void *map_sysmem(phys_addr_t paddr, unsigned long len) +{ + return map_physmem(paddr, len, MAP_WRBACK); +} + +static inline void unmap_sysmem(const void *vaddr) +{ +} diff --git a/include/common.h b/include/common.h index f2035c0..08d01db 100644 --- a/include/common.h +++ b/include/common.h @@ -861,6 +861,18 @@ int cpu_disable(int nr); int cpu_release(int nr, int argc, char * const argv[]); #endif +/* Define a null map_sysmem() if the architecture doesn't use it */ +# ifndef CONFIG_ARCH_MAP_SYSMEM +static inline void *map_sysmem(phys_addr_t paddr, unsigned long len) +{ + return (void *)(uintptr_t)paddr; +} + +static inline void unmap_sysmem(const void *vaddr) +{ +} +# endif + #endif /* __ASSEMBLY__ */ #ifdef CONFIG_PPC