ARM: multi_v7_defconfig: Switch BCM2835 to sdhci-iproc.c for MMC
[linux/fpc-iii.git] / arch / m68k / include / asm / page_mm.h
blobe7a1946455a88a295afb4d9a7b16607e626c5943
1 #ifndef _M68K_PAGE_MM_H
2 #define _M68K_PAGE_MM_H
4 #ifndef __ASSEMBLY__
6 #include <linux/compiler.h>
7 #include <asm/module.h>
9 /*
10 * We don't need to check for alignment etc.
12 #ifdef CPU_M68040_OR_M68060_ONLY
13 static inline void copy_page(void *to, void *from)
15 unsigned long tmp;
17 __asm__ __volatile__("1:\t"
18 ".chip 68040\n\t"
19 "move16 %1@+,%0@+\n\t"
20 "move16 %1@+,%0@+\n\t"
21 ".chip 68k\n\t"
22 "dbra %2,1b\n\t"
23 : "=a" (to), "=a" (from), "=d" (tmp)
24 : "0" (to), "1" (from) , "2" (PAGE_SIZE / 32 - 1)
28 static inline void clear_page(void *page)
30 unsigned long tmp;
31 unsigned long *sp = page;
33 *sp++ = 0;
34 *sp++ = 0;
35 *sp++ = 0;
36 *sp++ = 0;
38 __asm__ __volatile__("1:\t"
39 ".chip 68040\n\t"
40 "move16 %2@+,%0@+\n\t"
41 ".chip 68k\n\t"
42 "subqw #8,%2\n\t"
43 "subqw #8,%2\n\t"
44 "dbra %1,1b\n\t"
45 : "=a" (sp), "=d" (tmp)
46 : "a" (page), "0" (sp),
47 "1" ((PAGE_SIZE - 16) / 16 - 1));
50 #else
51 #define clear_page(page) memset((page), 0, PAGE_SIZE)
52 #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
53 #endif
55 #define clear_user_page(addr, vaddr, page) \
56 do { clear_page(addr); \
57 flush_dcache_page(page); \
58 } while (0)
59 #define copy_user_page(to, from, vaddr, page) \
60 do { copy_page(to, from); \
61 flush_dcache_page(page); \
62 } while (0)
64 extern unsigned long m68k_memoffset;
66 #ifndef CONFIG_SUN3
68 #define WANT_PAGE_VIRTUAL
70 static inline unsigned long ___pa(void *vaddr)
72 unsigned long paddr;
73 asm (
74 "1: addl #0,%0\n"
75 m68k_fixup(%c2, 1b+2)
76 : "=r" (paddr)
77 : "0" (vaddr), "i" (m68k_fixup_memoffset));
78 return paddr;
80 #define __pa(vaddr) ___pa((void *)(long)(vaddr))
81 static inline void *__va(unsigned long paddr)
83 void *vaddr;
84 asm (
85 "1: subl #0,%0\n"
86 m68k_fixup(%c2, 1b+2)
87 : "=r" (vaddr)
88 : "0" (paddr), "i" (m68k_fixup_memoffset));
89 return vaddr;
92 #else /* !CONFIG_SUN3 */
93 /* This #define is a horrible hack to suppress lots of warnings. --m */
94 #define __pa(x) ___pa((unsigned long)(x))
95 static inline unsigned long ___pa(unsigned long x)
97 if(x == 0)
98 return 0;
99 if(x >= PAGE_OFFSET)
100 return (x-PAGE_OFFSET);
101 else
102 return (x+0x2000000);
105 static inline void *__va(unsigned long x)
107 if(x == 0)
108 return (void *)0;
110 if(x < 0x2000000)
111 return (void *)(x+PAGE_OFFSET);
112 else
113 return (void *)(x-0x2000000);
115 #endif /* CONFIG_SUN3 */
118 * NOTE: virtual isn't really correct, actually it should be the offset into the
119 * memory node, but we have no highmem, so that works for now.
120 * TODO: implement (fast) pfn<->pgdat_idx conversion functions, this makes lots
121 * of the shifts unnecessary.
123 #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
124 #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
126 extern int m68k_virt_to_node_shift;
128 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
129 #define __virt_to_node(addr) (&pg_data_map[0])
130 #else
131 extern struct pglist_data *pg_data_table[];
133 static inline __attribute_const__ int __virt_to_node_shift(void)
135 int shift;
137 asm (
138 "1: moveq #0,%0\n"
139 m68k_fixup(%c1, 1b)
140 : "=d" (shift)
141 : "i" (m68k_fixup_vnode_shift));
142 return shift;
145 #define __virt_to_node(addr) (pg_data_table[(unsigned long)(addr) >> __virt_to_node_shift()])
146 #endif
148 #define virt_to_page(addr) ({ \
149 pfn_to_page(virt_to_pfn(addr)); \
151 #define page_to_virt(page) ({ \
152 pfn_to_virt(page_to_pfn(page)); \
155 #define pfn_to_page(pfn) ({ \
156 unsigned long __pfn = (pfn); \
157 struct pglist_data *pgdat; \
158 pgdat = __virt_to_node((unsigned long)pfn_to_virt(__pfn)); \
159 pgdat->node_mem_map + (__pfn - pgdat->node_start_pfn); \
161 #define page_to_pfn(_page) ({ \
162 const struct page *__p = (_page); \
163 struct pglist_data *pgdat; \
164 pgdat = &pg_data_map[page_to_nid(__p)]; \
165 ((__p) - pgdat->node_mem_map) + pgdat->node_start_pfn; \
168 #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
169 #define pfn_valid(pfn) virt_addr_valid(pfn_to_virt(pfn))
171 #endif /* __ASSEMBLY__ */
173 #endif /* _M68K_PAGE_MM_H */