]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
sandbox: Provide a way to map from host RAM to U-Boot RAM
authorSimon Glass <sjg@chromium.org>
Sat, 20 Apr 2013 08:42:37 +0000 (08:42 +0000)
committerTom Rini <trini@ti.com>
Wed, 1 May 2013 15:17:21 +0000 (11:17 -0400)
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>
arch/sandbox/cpu/cpu.c
arch/sandbox/include/asm/io.h
include/common.h

index b2788d5d536280a55733d3b43a764eb05bb3c7b1..dd8d495e3fc039fd3cea297b383f34103239de8a 100644 (file)
@@ -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)
 {
 }
index d8c02364d9e811186eb0550fd39a0e3eb2e376c9..54051a3bbbc034c17ff2387de66c8d9eb1df2322 100644 (file)
@@ -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);
index 0cfa6a837081cfe87118fcf44795a60ce126e77d..76c79ae58e4eb9512a33aa413fc65d698f03ca74 100644 (file)
@@ -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__ */