Skip to contentSkip to conversation

Introduce virt_to_phys()

PATCH New Kumar Gala 4 participants 15 messages Dec 13, 2008 – Dec 17, 2008

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH v4 1/4 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.

---

* No change, just reposting as part of the sequence

- k

 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
author
#1 lore raw

PATCH v4 2/4 Introduce addr_map library

Add a library that helps in translating between virtual and physical addresses. This library can be useful as a simple means to implement map_physmem() and virt_to_phys() for platforms that need functionality beyond the simple 1:1 mapping.

---
* Folded in Becky's phys_size_t changes

 include/addr_map.h     |   29 +++++++++++++++++
 lib_generic/Makefile   |    1 +
 lib_generic/addr_map.c |   81 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+), 0 deletions(-)
 create mode 100644 include/addr_map.h
 create mode 100644 lib_generic/addr_map.c
include/addr_map.h new file +29 -0
new file mode 100644
index 0000000..d55f5f6
@@ -0,0 +1,29 @@
+#ifndef __ADDR_MAP_H
+#define __ADDR_MAP_H
+
+/*
+ * Copyright 2008 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * Version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <asm/types.h>
+
+extern phys_addr_t addrmap_virt_to_phys(void *vaddr);
+extern unsigned long addrmap_phys_to_virt(phys_addr_t paddr);
+extern void addrmap_set_entry(unsigned long vaddr, phys_addr_t paddr,
+				phys_size_t size, int idx);
+
+#endif
lib_generic/Makefile +1 -0
index d62c39b..3f04022 100644
@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)libgeneric.a
 
+COBJS-$(CONFIG_ADDR_MAP) += addr_map.o
 COBJS-y += bzlib.o
 COBJS-y += bzlib_crctable.o
 COBJS-y += bzlib_decompress.o
lib_generic/addr_map.c new file +81 -0

81 lines not on this page · raw message

Signature · 1 line
1.5.6.5
author
#2 lore raw

PATCH v4 3/4 85xx: Add support to populate addr map based on TLB settings

---
* Folded in Becky's phys_size_t changes

 cpu/mpc85xx/tlb.c     |   34 ++++++++++++++++++++++++++++++++++
 include/asm-ppc/mmu.h |    3 +++
 lib_ppc/board.c       |    8 ++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)
cpu/mpc85xx/tlb.c +34 -0
index a2d16ae..5b5f791 100644
@@ -26,6 +26,11 @@
 #include <common.h>
 #include <asm/processor.h>
 #include <asm/mmu.h>
+#ifdef CONFIG_ADDR_MAP
+#include <addr_map.h>
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
 
 void set_tlb(u8 tlb, u32 epn, u64 rpn,
 	     u8 perms, u8 wimge,
@@ -47,6 +52,11 @@ void set_tlb(u8 tlb, u32 epn, u64 rpn,
 	mtspr(MAS7, _mas7);
 #endif
 	asm volatile("isync;msync;tlbwe;isync");
+
+#ifdef CONFIG_ADDR_MAP
+	if ((tlb == 1) && (gd->flags & GD_FLG_RELOC))
+		addrmap_set_entry(epn, rpn, (1UL << ((tsize * 2) + 10)), esel);
+#endif
 }
 
 void disable_tlb(u8 esel)
@@ -67,6 +77,11 @@ void disable_tlb(u8 esel)
 	mtspr(MAS7, _mas7);
 #endif
 	asm volatile("isync;msync;tlbwe;isync");
+
+#ifdef CONFIG_ADDR_MAP
+	if (gd->flags & GD_FLG_RELOC)
+		addrmap_set_entry(0, 0, 0, esel);
+#endif
 }
 
 void invalidate_tlb(u8 tlb)
@@ -91,6 +106,25 @@ void init_tlbs(void)
 	return ;
 }
 
+#ifdef CONFIG_ADDR_MAP
+void init_addr_map(void)
+{
+	int i;
+
+	for (i = 0; i < num_tlb_entries; i++) {
+		if (tlb_table[i].tlb == 0)
+			continue;
+
+		addrmap_set_entry(tlb_table[i].epn,
+			tlb_table[i].rpn,
+			(1UL << ((tlb_table[i].tsize * 2) + 10)),
+			tlb_table[i].esel);
+	}
+
+	return ;
+}
+#endif
+
 unsigned int setup_ddr_tlbs(unsigned int memsize_in_meg)
 {
 	unsigned int tlb_size;
include/asm-ppc/mmu.h +3 -0
index 8975e6c..6d942d0 100644
@@ -431,6 +431,9 @@ extern void set_tlb(u8 tlb, u32 epn, u64 rpn,
 extern void disable_tlb(u8 esel);
 extern void invalidate_tlb(u8 tlb);
 extern void init_tlbs(void);
+#ifdef CONFIG_ADDR_MAP
+extern void init_addr_map(void);
+#endif
 extern unsigned int setup_ddr_tlbs(unsigned int memsize_in_meg);
 
 #define SET_TLB_ENTRY(_tlb, _epn, _rpn, _perms, _wimge, _ts, _esel, _sz, _iprot) \
lib_ppc/board.c +8 -0
index 289a32a..61c29b5 100644
@@ -75,6 +75,10 @@
 #include <keyboard.h>
 #endif
 
+#ifdef CONFIG_ADDR_MAP
+#include <asm/mmu.h>
+#endif
+
 #ifdef CONFIG_SYS_UPDATE_FLASH_SIZE
 extern int update_flash_size (int flash_size);
 #endif
@@ -694,6 +698,10 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	 */
 	trap_init (dest_addr);
 
+#if defined(CONFIG_ADDR_MAP) && defined(CONFIG_E500)
+	init_addr_map();
+#endif
+
 #if defined(CONFIG_BOARD_EARLY_INIT_R)
 	board_early_init_r ();
 #endif
Signature · 1 line
1.5.6.5
author
#3 lore raw

PATCH v4 4/4 ppc: Use addrmap in virt_to_phys and map_physmem.

If we have addr map support enabled use the mapping functions to implement virt_to_phys() and map_physmem().

---
* No change, just reposting as part of the sequence

 include/asm-ppc/io.h |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
include/asm-ppc/io.h +12 -0
index c00de45..a8003ef 100644
@@ -10,6 +10,10 @@
 #include <linux/config.h>
 #include <asm/byteorder.h>
 
+#ifdef CONFIG_ADDR_MAP
+#include <addr_map.h>
+#endif
+
 #define SIO_CONFIG_RA   0x398
 #define SIO_CONFIG_RD   0x399
 
@@ -287,7 +291,11 @@ extern inline void out_be32(volatile unsigned __iomem *addr, int val)
 static inline void *
 map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
 {
+#ifdef CONFIG_ADDR_MAP
+	return (void *)(addrmap_phys_to_virt(paddr));
+#else
 	return (void *)((unsigned long)paddr);
+#endif
 }
 
 /*
@@ -300,7 +308,11 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 static inline phys_addr_t virt_to_phys(void * vaddr)
 {
+#ifdef CONFIG_ADDR_MAP
+	return addrmap_virt_to_phys(vaddr);
+#else
 	return (phys_addr_t)(vaddr);
+#endif
 }
 
 #endif
Signature · 1 line
1.5.6.5
#4 lore raw

PATCH v4 2/4 Introduce addr_map library

In reply to Kumar Gala

Dear Kumar Gala,

Quoted 9 lines · In message <[email protected]> you…

Add a library that helps in translating between virtual and physical addresses. This library can be useful as a simple means to implement map_physmem() and virt_to_phys() for platforms that need functionality beyond the simple 1:1 mapping.

---
* Folded in Becky's phys_size_t changes

Quoted 6 lines
 include/addr_map.h     |   29 +++++++++++++++++
 lib_generic/Makefile   |    1 +
 lib_generic/addr_map.c |   81 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+), 0 deletions(-)
 create mode 100644 include/addr_map.h
 create mode 100644 lib_generic/addr_map.c

Applied, thanks.

As discussed, I'll be leaving patches 3/4 and 4/4 of this series for Andy to pick them up.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The joys of love made her human and the  agonies  of  love  destroyed
her.
	-- Spock, "Requiem for Methuselah", stardate 5842.8
author
#5 lore raw

PATCH v4 2/4 Introduce addr_map library

Quoted 22 lines · Wolfgang Denk

Dear Kumar Gala,

In message <1229210430-4522-2-git-send-email-

Quoted 10 lines · galak at kernel.crashing.org> you wrote:

Add a library that helps in translating between virtual and physical addresses. This library can be useful as a simple means to implement map_physmem() and virt_to_phys() for platforms that need functionality
beyond the simple 1:1 mapping.

---
* Folded in Becky's phys_size_t changes

Quoted 7 lines
include/addr_map.h     |   29 +++++++++++++++++
lib_generic/Makefile   |    1 +
lib_generic/addr_map.c |   81 ++++++++++++++++++++++++++++++++++++++ 
++++++++++
3 files changed, 111 insertions(+), 0 deletions(-)

create mode 100644 include/addr_map.h
create mode 100644 lib_generic/addr_map.c

Quoted 4 lines

Applied, thanks.

As discussed, I'll be leaving patches 3/4 and 4/4 of this series for Andy to pick them up.

just to be clear are you thinking for this upcoming release or the one following it?

- k

#6 lore raw

PATCH v4 2/4 Introduce addr_map library

Dear Kumar,

Quoted 25 lines · In message <[email protected]> you wrote:
Quoted 22 lines · Wolfgang Denk

Dear Kumar Gala,

In message <1229210430-4522-2-git-send-email-

Quoted 17 lines · galak at kernel.crashing.org> you wrote:

Add a library that helps in translating between virtual and physical addresses. This library can be useful as a simple means to implement map_physmem() and virt_to_phys() for platforms that need functionality
beyond the simple 1:1 mapping.

---
* Folded in Becky's phys_size_t changes

include/addr_map.h     |   29 +++++++++++++++++
lib_generic/Makefile   |    1 +
lib_generic/addr_map.c |   81 ++++++++++++++++++++++++++++++++++++++ 
++++++++++
3 files changed, 111 insertions(+), 0 deletions(-)

create mode 100644 include/addr_map.h
create mode 100644 lib_generic/addr_map.c

Quoted 1 line
Quoted 1 line

Applied, thanks.

I'm afraid your patch causes problems on the Katmai board:

Configuring for katmai board...
In file included from 44x_spd_ddr2.c:46:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from display_options.c:27:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from 4xx_pcie.c:32:
/home/wd/git/u-boot/work/include/asm-ppc/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm-ppc/io.h:303: warning: cast from pointer to integer of different size In file included from bat_rw.c:28:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from commproc.c:29:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from denali_data_eye.c:38:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from denali_spd_ddr2.c:45:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from ecc.c:44:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from i2c.c:33:
/home/wd/git/u-boot/work/include/asm-ppc/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm-ppc/io.h:303: warning: cast from pointer to integer of different size In file included from iop480_uart.c:27:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from tlb.c:30:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from 4xx_uart.c:47:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from gpio.c:26:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from miiphy.c:39:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from systemace.c:45:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from cfi_flash.c:39:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from eepro100.c:28:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from pci.c:35:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from 4xx_enet.c:84:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from pci_indirect.c:17:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from cmd_pcmcia.c:60:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from cmd_pci.c:35:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from memsize.c:30:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size In file included from katmai.c:32:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
text data bss dec hex filename
268208 15484 127736 411428 64724 ./u-boot

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"In matrimony, to hesitate is sometimes to be saved."        - Butler
#7 lore raw

PATCH v4 2/4 Introduce addr_map library

Quoted 34 lines · Wolfgang Denk

Dear Kumar,

In message <8FDAD51E-151A-43C8-

Quoted 28 lines · BFB2-101B8277EC74 at kernel.crashing.org> you wrote:
Quoted 25 lines · Wolfgang Denk

Dear Kumar Gala,

In message <1229210430-4522-2-git-send-email-

Quoted 20 lines · galak at kernel.crashing.org> you wrote:

Add a library that helps in translating between virtual and physical
addresses. This library can be useful as a simple means to implement
map_physmem() and virt_to_phys() for platforms that need functionality
beyond the simple 1:1 mapping.

---
* Folded in Becky's phys_size_t changes

include/addr_map.h     |   29 +++++++++++++++++
lib_generic/Makefile   |    1 +
lib_generic/addr_map.c |   81 ++++++++++++++++++++++++++++++++++++ 
++
++++++++++
3 files changed, 111 insertions(+), 0 deletions(-)

create mode 100644 include/addr_map.h
create mode 100644 lib_generic/addr_map.c

Quoted 1 line
Quoted 1 line

Applied, thanks.

Quoted 7 lines

I'm afraid your patch causes problems on the Katmai board:

Configuring for katmai board...
In file included from 44x_spd_ddr2.c:46:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size

There was a patch in my series that fixed this:

[PATCH 01/11] powerpc: fix io.h build warning with CONFIG_PHYS_64BIT

That really needs to become part of Kumar's series since katmai has 64bit enabled.

-Becky

Quoted 112 lines

In file included from display_options.c:27:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from 4xx_pcie.c:32:
/home/wd/git/u-boot/work/include/asm-ppc/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm-ppc/io.h:303: warning: cast from pointer to integer of different size
In file included from bat_rw.c:28:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from commproc.c:29:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from denali_data_eye.c:38:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from denali_spd_ddr2.c:45:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from ecc.c:44:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from i2c.c:33:
/home/wd/git/u-boot/work/include/asm-ppc/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm-ppc/io.h:303: warning: cast from pointer to integer of different size
In file included from iop480_uart.c:27:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from tlb.c:30:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from 4xx_uart.c:47:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from gpio.c:26:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from miiphy.c:39:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from systemace.c:45:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from cfi_flash.c:39:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from eepro100.c:28:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from pci.c:35:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from 4xx_enet.c:84:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from pci_indirect.c:17:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from cmd_pcmcia.c:60:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from cmd_pci.c:35:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from memsize.c:30:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
In file included from katmai.c:32:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size
text data bss dec hex filename
268208 15484 127736 411428 64724 ./u-boot

Best regards,

Wolfgang Denk

Signature · 8 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"In matrimony, to hesitate is sometimes to be saved."        - Butler
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
#8 lore raw

PATCH v4 2/4 Introduce addr_map library

Dear Becky,

Quoted 1 line · In message <[email protected]> you wrote:

...

Quoted 6 lines
Quoted 5 lines

Configuring for katmai board...
In file included from 44x_spd_ddr2.c:46:
/home/wd/git/u-boot/work/include/asm/io.h: In function 'virt_to_phys':
/home/wd/git/u-boot/work/include/asm/io.h:303: warning: cast from pointer to integer of different size

Quoted 6 lines

There was a patch in my series that fixed this:

[PATCH 01/11] powerpc: fix io.h build warning with CONFIG_PHYS_64BIT

That really needs to become part of Kumar's series since katmai has 64bit enabled.

Thanks for the pointer. I'll pick up that patch now directly.

Hm...

Applying: powerpc: fix io.h build warning with CONFIG_PHYS_64BIT
error: patch failed: include/asm-ppc/io.h:311
error: include/asm-ppc/io.h: patch does not apply
fatal: sha1 information is lacking or useless (include/asm-ppc/io.h). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge.
Patch failed at 0001.

Hm... manually applied.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Violence in reality is quite different from theory.
	-- Spock, "The Cloud Minders", stardate 5818.4
#9 lore raw

PATCH v4 1/4 Introduce virt_to_phys()

In reply to Kumar Gala

Dear Kumar Gala,

Quoted 14 lines · In message <[email protected]> you…

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.

---

* No change, just reposting as part of the sequence

- k

Quoted 13 lines
 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(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When you say "I wrote a program that crashed  Windows",  people  just
stare  at you blankly and say "Hey, I got those with the system, *for
free*".        - Linus Torvalds in <[email protected]>
#10 lore raw

PATCH v4 1/4 Introduce virt_to_phys()

In reply to Kumar Gala

include/asm-avr32/io.h static inline void unmap_physmem(void *vaddr, unsigned long len) · line 132

Quoted 13 lines · Kumar Gala
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);
+}
+

avr32 has already got one of those, so this breaks the build.

I'm going to apply the patch below to my 'fixes' branch if it looks ok to you.

Haavard

author
#11 lore raw

PATCH v4 1/4 Introduce virt_to_phys()

Quoted 18 lines · Haavard Skinnemoen
Quoted 5 lines · Kumar Gala
include/asm-avr32/io.h +0 -0
index 06e52b1..d22cd35 100644

include/asm-avr32/io.h static inline void unmap_physmem(void *vaddr, · line 133

Quoted 9 lines
include/asm-avr32/io.h +5 -0
@@ -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);
+}
+

avr32 has already got one of those, so this breaks the build.

Quoted 2 lines

I'm going to apply the patch below to my 'fixes' branch if it looks ok to you.

sorry about that.

Quoted 25 lines

Haavard

From 92c78a3bbcb2ce508b4bf1c4a1e0940406a024bb Mon Sep 17 00:00:00 2001
From: Haavard Skinnemoen <[email protected]>
Date: Wed, 17 Dec 2008 16:43:18 +0100
Subject: [PATCH] avr32: Remove second definition of virt_to_phys()

The second definition introduced by 65e43a1063 conflicts with the existing one.

Also, convert the existing definition to use phys_addr_t. The volatile qualifier is still needed due to brain damage elsewhere.

---
include/asm-avr32/io.h | 9 ++-------

1 files changed, 2 insertions(+), 7 deletions(-)
include/asm-avr32/io.h +0 -0
index d22cd35..50967ac 100644

include/asm-avr32/io.h extern void __readwrite_bug(const char *fn); · line 80

Quoted 6 lines
include/asm-avr32/io.h +1 -1
@@ -76,12 +76,12 @@ extern void __readwrite_bug(const char *fn);
 #include <asm/addrspace.h>
 
 /* virt_to_phys will only work when address is in P1 or P2 */
-static __inline__ unsigned long virt_to_phys(volatile void *address)
+static inline phys_addr_t virt_to_phys(volatile void *address)
 {

Is the volatile really needed?

Quoted 22 lines
include/asm-avr32/io.h +1 -6
 	return PHYSADDR(address);
 }
 
-static __inline__ void * phys_to_virt(unsigned long address)
+static inline void *phys_to_virt(phys_addr_t address)
 {
 	return (void *)P1SEGADDR(address);
 }
@@ -125,9 +125,4 @@ 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 */

Signature · 1 line
1.5.6.3
#12 lore raw

PATCH v4 1/4 Introduce virt_to_phys()

Quoted 6 lines · Kumar Gala
Quoted 4 lines

/* virt_to_phys will only work when address is in P1 or P2 */

(quoted diff) +1 -1
-static __inline__ unsigned long virt_to_phys(volatile void *address)
+static inline phys_addr_t virt_to_phys(volatile void *address)

{

Is the volatile really needed?

The problem is that the 'packet' parameter to struct eth_device.send() is volatile, and it propagates into this function. So if I remove the volatile, I have to either add ugly casts elsewhere or change the eth_device API...

I have no idea why the network subsystem feels the need to enforce the use of volatile in all drivers, though...

Haavard

author
#13 lore raw

PATCH v4 1/4 Introduce virt_to_phys()

Quoted 9 lines · Haavard Skinnemoen
Quoted 7 lines · Kumar Gala
Quoted 5 lines

/* virt_to_phys will only work when address is in P1 or P2 */ -static __inline__ unsigned long virt_to_phys(volatile void *address)
+static inline phys_addr_t virt_to_phys(volatile void *address) {

Is the volatile really needed?

Quoted 7 lines

The problem is that the 'packet' parameter to struct eth_device.send() is volatile, and it propagates into this function. So if I remove the volatile, I have to either add ugly casts elsewhere or change the eth_device API...

I have no idea why the network subsystem feels the need to enforce the use of volatile in all drivers, though...

Lets go w/volatile for now and worry about this post v2009.01

- k

#14 lore raw

PATCH v4 1/4 Introduce virt_to_phys()

Quoted 1 line · Kumar Gala

Lets go w/volatile for now and worry about this post v2009.01

Sounds good to me.

Haavard