1 #ifndef __VIRT_CONVERT__
2 #define __VIRT_CONVERT__
3
4 /*
5 * Macros used for converting between virtual and physical mappings.
6 */
7
8 #ifdef __KERNEL__
9
10 #include <linux/config.h>
11 #include <asm/setup.h>
12 #include <asm/page.h>
13
14 #ifdef CONFIG_AMIGA
15 #include <asm/amigahw.h>
16 #endif
17
18 /*
19 * Change virtual addresses to physical addresses and vv.
20 */
21 #ifndef CONFIG_SUN3
22 extern unsigned long mm_vtop(unsigned long addr) __attribute__ ((const));
23 extern unsigned long mm_vtop_fallback (unsigned long) __attribute__ ((const));
24 extern unsigned long mm_ptov(unsigned long addr) __attribute__ ((const));
25 #else
26 extern inline unsigned long mm_vtop(unsigned long vaddr)
27 {
28 return __pa(vaddr);
29 }
30
31 extern inline unsigned long mm_ptov(unsigned long paddr)
32 {
33 return (unsigned long)__va(paddr);
34 }
35 #endif
36
37 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
38 extern inline unsigned long virt_to_phys(volatile void *vaddr)
39 {
40 unsigned long voff = (unsigned long)vaddr - PAGE_OFFSET;
41
42 if (voff < m68k_memory[0].size)
43 return voff + m68k_memory[0].addr;
44 return mm_vtop_fallback((unsigned long)vaddr);
45 }
46
47 extern inline void * phys_to_virt(unsigned long paddr)
48 {
49 unsigned long poff = paddr - m68k_memory[0].addr;
50
51 if (poff < m68k_memory[0].size)
52 return (void *)(poff + PAGE_OFFSET);
53
54 #ifdef CONFIG_AMIGA
55 /*
56 * if on an amiga and address is in first 16M, move it
57 * to the ZTWO_VADDR range
58 */
59 if (MACH_IS_AMIGA && paddr < 16*1024*1024)
60 return (void *)ZTWO_VADDR(paddr);
61 #endif
62 return (void *)paddr;
63 }
64 #else
65 extern inline unsigned long virt_to_phys(volatile void * address)
66 {
67 return mm_vtop((unsigned long)address);
68 }
69
70 extern inline void * phys_to_virt(unsigned long address)
71 {
72 return (void *) mm_ptov(address);
73 }
74 #endif
75
76 /*
77 * IO bus memory addresses are 1:1 with the physical address,
78 * except on the PCI bus of the Hades.
79 */
80 #ifdef CONFIG_HADES
81 #define virt_to_bus(a) (virt_to_phys(a) + (MACH_IS_HADES ? 0x80000000 : 0))
82 #define bus_to_virt(a) (phys_to_virt((a) - (MACH_IS_HADES ? 0x80000000 : 0)))
83 #else
84 #define virt_to_bus virt_to_phys
85 #define bus_to_virt phys_to_virt
86 #endif
87
88 #endif
89 #endif
90
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.