Skip to contentSkip to conversation

Introduce virt_to_phys()

PATCH Superseded Kumar Gala 1 participant 1 message Nov 24, 2008

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/3 Introduce virt_to_phys()

virt_to_phys() returns the physical address given a virtual. In most cases this will just the input value as the vast majority of systems run in a 1:1 mode.

However in systems that are not running this way it should report the physical address or ~0 if no mapping exists for the given virtual address.

---
 include/asm-arm/io.h        |    5 +++++
 include/asm-avr32/io.h      |    5 +++++
 include/asm-blackfin/io.h   |    5 +++++
 include/asm-i386/io.h       |    5 +++++
 include/asm-m68k/io.h       |    5 +++++
 include/asm-microblaze/io.h |    5 +++++
 include/asm-mips/io.h       |    2 +-
 include/asm-nios/io.h       |    5 +++++
 include/asm-nios2/io.h      |    5 +++++
 include/asm-ppc/io.h        |    5 +++++
 include/asm-sh/io.h         |    5 +++++
 include/asm-sparc/io.h      |    5 +++++
 12 files changed, 56 insertions(+), 1 deletions(-)
include/asm-arm/io.h +5 -0
index f4ae307..fec3a7e 100644
@@ -57,6 +57,11 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(vaddr);
+}
+
 /*
  * Generic virtual read/write.  Note that we don't support half-word
  * read/writes.  We define __arch_*[bl] here, and leave __arch_*w
include/asm-avr32/io.h +5 -0
index 06e52b1..d22cd35 100644
@@ -125,4 +125,9 @@ static inline void unmap_physmem(void *vaddr, unsigned long len)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(vaddr);
+}
+
 #endif /* __ASM_AVR32_IO_H */
include/asm-blackfin/io.h +5 -0
index da58914..6806494 100644
@@ -64,6 +64,11 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(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
include/asm-i386/io.h +5 -0
index 2c57140..9b757d4 100644
@@ -229,4 +229,9 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(vaddr);
+}
+
 #endif
include/asm-m68k/io.h +5 -0
index 1fccc12..50ea087 100644
@@ -251,4 +251,9 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(vaddr);
+}
+
 #endif				/* __ASM_M68K_IO_H__ */
include/asm-microblaze/io.h +5 -0
index 8804724..7e190d1 100644
@@ -155,4 +155,9 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(vaddr);
+}
+
 #endif /* __MICROBLAZE_IO_H__ */
include/asm-mips/io.h +1 -1
index 3a0f33f..031186d 100644
@@ -118,7 +118,7 @@ static inline void set_io_port_base(unsigned long base)
  * Change virtual addresses to physical addresses and vv.
  * These are trivial on the 1:1 Linux/MIPS mapping
  */
-extern inline unsigned long virt_to_phys(volatile void * address)
+extern inline phys_addr_t virt_to_phys(void * address)
 {
 	return CPHYSADDR(address);
 }
include/asm-nios/io.h +5 -0
index 8b78806..899682c 100644
@@ -133,4 +133,9 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(vaddr);
+}
+
 #endif /* __ASM_NIOS_IO_H_ */
include/asm-nios2/io.h +5 -0
index 2f1ec26..01d11ef 100644
@@ -53,6 +53,11 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(vaddr);
+}
+
 extern unsigned char inb (unsigned char *port);
 extern unsigned short inw (unsigned short *port);
 extern unsigned inl (unsigned port);
include/asm-ppc/io.h +5 -0
index c349681..c00de45 100644
@@ -298,4 +298,9 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(vaddr);
+}
+
 #endif
include/asm-sh/io.h +5 -0
index adc3f81..ca598a6 100644
@@ -261,5 +261,10 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(vaddr);
+}
+
 #endif	/* __KERNEL__ */
 #endif	/* __ASM_SH_IO_H */
include/asm-sparc/io.h +5 -0
index 5f8d05c..0c5d86c 100644
@@ -90,4 +90,9 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+static inline phys_addr_t virt_to_phys(void * vaddr)
+{
+	return (phys_addr_t)(vaddr);
+}
+
 #endif
Signature · 1 line
1.5.6.5