* add p cc
[mascara-docs.git] / i386 / linux / linux-2.3.21 / include / asm-m68k / virtconvert.h
blob302308d886ce7b289a9829240c5ceef5b3b1a48d
1 #ifndef __VIRT_CONVERT__
2 #define __VIRT_CONVERT__
4 /*
5 * Macros used for converting between virtual and physical mappings.
6 */
8 #ifdef __KERNEL__
10 #include <linux/config.h>
11 #include <asm/setup.h>
13 #ifdef CONFIG_AMIGA
14 #include <asm/amigahw.h>
15 #endif
18 * Change virtual addresses to physical addresses and vv.
20 #ifndef CONFIG_SUN3
21 extern unsigned long mm_vtop(unsigned long addr) __attribute__ ((const));
22 extern unsigned long mm_vtop_fallback (unsigned long) __attribute__ ((const));
23 extern unsigned long mm_ptov(unsigned long addr) __attribute__ ((const));
24 #else
25 extern inline unsigned long mm_vtop(unsigned long vaddr)
27 return __pa(vaddr);
30 extern inline unsigned long mm_ptov(unsigned long paddr)
32 return (unsigned long)__va(paddr);
34 #endif
36 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
37 extern inline unsigned long virt_to_phys(volatile void * address)
39 unsigned long voff = (unsigned long) address;
41 if (voff < m68k_memory[0].size)
42 return m68k_memory[0].addr + voff;
43 else
44 return mm_vtop_fallback(voff);
47 extern inline void * phys_to_virt(unsigned long paddr)
49 unsigned long base = m68k_memory[0].addr;
51 if ((paddr >= base) && (paddr < (base + m68k_memory[0].size)))
52 return (void *)(paddr - base);
53 #ifdef CONFIG_AMIGA
55 * if on an amiga and address is in first 16M, move it
56 * to the ZTWO_VADDR range
58 if (MACH_IS_AMIGA && paddr < 16*1024*1024)
59 return (void *)ZTWO_VADDR(paddr);
60 #endif
61 return (void *)paddr;
63 #else
64 extern inline unsigned long virt_to_phys(volatile void * address)
66 return mm_vtop((unsigned long)address);
69 extern inline void * phys_to_virt(unsigned long address)
71 return (void *) mm_ptov(address);
73 #endif
76 * IO bus memory addresses are 1:1 with the physical address,
77 * except on the PCI bus of the Hades.
79 #ifdef CONFIG_HADES
80 #define virt_to_bus(a) (virt_to_phys(a) + (MACH_IS_HADES ? 0x80000000 : 0))
81 #define bus_to_virt(a) (phys_to_virt((a) - (MACH_IS_HADES ? 0x80000000 : 0)))
82 #else
83 #define virt_to_bus virt_to_phys
84 #define bus_to_virt phys_to_virt
85 #endif
87 #endif
88 #endif