summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-04-20 08:42:37 +0000
committerTom Rini <trini@ti.com>2013-05-01 11:17:21 -0400
commit781adb5710694601e8ceb01256becea142c5ba6c (patch)
tree8e2c0c7ea5e223e0dd0209afb3d09230f8e765d2
parentfada9e2048446878c95fb331bbc21e1e40eddc72 (diff)
downloadtalos-obmc-uboot-781adb5710694601e8ceb01256becea142c5ba6c.tar.gz
talos-obmc-uboot-781adb5710694601e8ceb01256becea142c5ba6c.zip
sandbox: Provide a way to map from host RAM to U-Boot RAM
In many cases, pointers to memory are passed around, and these pointers refer to U-Boot memory, not host memory. This in itself is not a problem. However, in a few places, we cast that pointer back to a ulong (being a U-Boot memory address). It is possible to convert many of these cases to avoid this. However there are data structures (e.g. struct bootm_headers) which use pointers. We could with a lot of effort adjust the structs and all code that uses them to use ulong instead of pointers. This seems like an unacceptable cost, since our objective with sandbox is to minimise the impact on U-Boot code while maximising the features available to sandbox. Therefore, create a map_to_sysmem() function which converts from a pointer to a U-Boot address. This can be used sparingly when needed. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--arch/sandbox/cpu/cpu.c5
-rw-r--r--arch/sandbox/include/asm/io.h3
-rw-r--r--include/common.h5
3 files changed, 13 insertions, 0 deletions
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index b2788d5d53..dd8d495e3f 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -57,6 +57,11 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
return (void *)(gd->arch.ram_buf + paddr);
}
+phys_addr_t map_to_sysmem(void *ptr)
+{
+ return (u8 *)ptr - gd->arch.ram_buf;
+}
+
void flush_dcache_range(unsigned long start, unsigned long stop)
{
}
diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index d8c02364d9..54051a3bbb 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -49,3 +49,6 @@ static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
static inline void unmap_sysmem(const void *vaddr)
{
}
+
+/* Map from a pointer to our RAM buffer */
+phys_addr_t map_to_sysmem(void *ptr);
diff --git a/include/common.h b/include/common.h
index 0cfa6a8370..76c79ae58e 100644
--- a/include/common.h
+++ b/include/common.h
@@ -897,6 +897,11 @@ static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
static inline void unmap_sysmem(const void *vaddr)
{
}
+
+static inline phys_addr_t map_to_sysmem(void *ptr)
+{
+ return (phys_addr_t)(uintptr_t)ptr;
+}
# endif
#endif /* __ASSEMBLY__ */
OpenPOWER on IntegriCloud