[U-Boot-Users] [PATCH 5/6] Introduce map_physmem() and unmap_physmem()

Haavard Skinnemoen hskinnemoen at atmel.com
Tue Dec 11 16:28:19 CET 2007


map_physmem() returns a virtual address which can be used to access a
given physical address without involving the cache. unmap_physmem()
should be called when the virtual address returned by map_physmem() is
no longer needed.

This patch adds a stub implementation which simply returns the
physical address cast to a uchar * for all architectures except AVR32,
which converts the physical address to an uncached virtual mapping.
unmap_physmem() is a no-op on all architectures, but if any
architecture needs to do such mappings through the TLB, this is the
hook where those TLB entries can be invalidated.

Signed-off-by: Haavard Skinnemoen <hskinnemoen at atmel.com>
---
 include/asm-arm/io.h        |   17 +++++++++++++++++
 include/asm-avr32/io.h      |   20 ++++++++++++++++++++
 include/asm-blackfin/io.h   |   17 +++++++++++++++++
 include/asm-i386/io.h       |   17 +++++++++++++++++
 include/asm-m68k/io.h       |   18 ++++++++++++++++++
 include/asm-microblaze/io.h |   17 +++++++++++++++++
 include/asm-mips/io.h       |   17 +++++++++++++++++
 include/asm-nios/io.h       |   17 +++++++++++++++++
 include/asm-nios2/io.h      |   17 +++++++++++++++++
 include/asm-ppc/io.h        |   17 +++++++++++++++++
 10 files changed, 174 insertions(+), 0 deletions(-)

diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index 47c18e7..8d6b37f 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -34,6 +34,23 @@ static inline void sync(void)
 }
 
 /*
+ * Given a physical address, return a virtual address that can be used
+ * to access it without going through the cache.
+ */
+static inline void *map_physmem(unsigned long paddr)
+{
+	return (void *)paddr;
+}
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr)
+{
+
+}
+
+/*
  * Generic virtual read/write.  Note that we don't support half-word
  * read/writes.  We define __arch_*[bl] here, and leave __arch_*w
  * to the architecture specific code.
diff --git a/include/asm-avr32/io.h b/include/asm-avr32/io.h
index 3c0d569..1616a00 100644
--- a/include/asm-avr32/io.h
+++ b/include/asm-avr32/io.h
@@ -93,4 +93,24 @@ static inline void sync(void)
 {
 }
 
+/*
+ * Given a physical address, return a virtual address that can be used
+ * to access it without going through the cache.
+ *
+ * This implementation works for memory below 512MiB (flash, etc.) as
+ * well as above 3.5GiB (internal peripherals.)
+ */
+static inline void *map_physmem(unsigned long paddr)
+{
+	return (void *)P2SEGADDR(paddr);
+}
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr)
+{
+
+}
+
 #endif /* __ASM_AVR32_IO_H */
diff --git a/include/asm-blackfin/io.h b/include/asm-blackfin/io.h
index 332d2c6..d84f79d 100644
--- a/include/asm-blackfin/io.h
+++ b/include/asm-blackfin/io.h
@@ -41,6 +41,23 @@ static inline void sync(void)
 }
 
 /*
+ * Given a physical address, return a virtual address that can be used
+ * to access it without going through the cache.
+ */
+static inline void *map_physmem(unsigned long paddr)
+{
+	return (void *)paddr;
+}
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr)
+{
+
+}
+
+/*
  * These are for ISA/PCI shared memory _only_ and should never be used
  * on any other type of memory, including Zorro memory. They are meant to
  * access the bus in the bus byte order which is little-endian!.
diff --git a/include/asm-i386/io.h b/include/asm-i386/io.h
index e64d788..fa38231 100644
--- a/include/asm-i386/io.h
+++ b/include/asm-i386/io.h
@@ -205,4 +205,21 @@ static inline void sync(void)
 {
 }
 
+/*
+ * Given a physical address, return a virtual address that can be used
+ * to access it without going through the cache.
+ */
+static inline void *map_physmem(unsigned long paddr)
+{
+	return (void *)paddr;
+}
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr)
+{
+
+}
+
 #endif
diff --git a/include/asm-m68k/io.h b/include/asm-m68k/io.h
index e14a581..73c1b13 100644
--- a/include/asm-m68k/io.h
+++ b/include/asm-m68k/io.h
@@ -218,4 +218,22 @@ static inline void sync(void)
 	 * compatibility (CFI driver)
 	 */
 }
+
+/*
+ * Given a physical address, return a virtual address that can be used
+ * to access it without going through the cache.
+ */
+static inline void *map_physmem(unsigned long paddr)
+{
+	return (void *)paddr;
+}
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr)
+{
+
+}
+
 #endif				/* __ASM_M68K_IO_H__ */
diff --git a/include/asm-microblaze/io.h b/include/asm-microblaze/io.h
index 1c77ade..9424c83 100644
--- a/include/asm-microblaze/io.h
+++ b/include/asm-microblaze/io.h
@@ -129,4 +129,21 @@ static inline void sync(void)
 {
 }
 
+/*
+ * Given a physical address, return a virtual address that can be used
+ * to access it without going through the cache.
+ */
+static inline void *map_physmem(unsigned long paddr)
+{
+	return (void *)paddr;
+}
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr)
+{
+
+}
+
 #endif /* __MICROBLAZE_IO_H__ */
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index 1e060f7..bacc288 100644
--- a/include/asm-mips/io.h
+++ b/include/asm-mips/io.h
@@ -465,4 +465,21 @@ static inline void sync(void)
 {
 }
 
+/*
+ * Given a physical address, return a virtual address that can be used
+ * to access it without going through the cache.
+ */
+static inline void *map_physmem(unsigned long paddr)
+{
+	return (void *)paddr;
+}
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr)
+{
+
+}
+
 #endif /* _ASM_IO_H */
diff --git a/include/asm-nios/io.h b/include/asm-nios/io.h
index d77695a..6c88918 100644
--- a/include/asm-nios/io.h
+++ b/include/asm-nios/io.h
@@ -101,4 +101,21 @@ static inline void sync(void)
 {
 }
 
+/*
+ * Given a physical address, return a virtual address that can be used
+ * to access it without going through the cache.
+ */
+static inline void *map_physmem(unsigned long paddr)
+{
+	return (void *)paddr;
+}
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr)
+{
+
+}
+
 #endif /* __ASM_NIOS_IO_H_ */
diff --git a/include/asm-nios2/io.h b/include/asm-nios2/io.h
index 5bb5322..e9aae72 100644
--- a/include/asm-nios2/io.h
+++ b/include/asm-nios2/io.h
@@ -29,6 +29,23 @@ static inline void sync(void)
 	__asm__ __volatile__ ("sync" : : : "memory");
 }
 
+/*
+ * Given a physical address, return a virtual address that can be used
+ * to access it without going through the cache.
+ */
+static inline void *map_physmem(unsigned long paddr)
+{
+	return (void *)paddr;
+}
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr)
+{
+
+}
+
 extern unsigned char inb (unsigned char *port);
 extern unsigned short inw (unsigned short *port);
 extern unsigned inl (unsigned port);
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index 11dfa1c..b8442f9 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -208,4 +208,21 @@ extern inline void out_be32(volatile unsigned __iomem *addr, int val)
 	__asm__ __volatile__("sync; stw%U0%X0 %1,%0" : "=m" (*addr) : "r" (val));
 }
 
+/*
+ * Given a physical address, return a virtual address that can be used
+ * to access it without going through the cache.
+ */
+static inline void *map_physmem(unsigned long paddr)
+{
+	return (void *)paddr;
+}
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr)
+{
+
+}
+
 #endif
-- 
1.5.3.4





More information about the U-Boot mailing list