1 #ifndef _M68K_PAGE_MM_H
2 #define _M68K_PAGE_MM_H
6 #include <linux/compiler.h>
7 #include <asm/module.h>
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
)
17 __asm__
__volatile__("1:\t"
19 "move16 %1@+,%0@+\n\t"
20 "move16 %1@+,%0@+\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
)
31 unsigned long *sp
= page
;
38 __asm__
__volatile__("1:\t"
40 "move16 %2@+,%0@+\n\t"
45 : "=a" (sp
), "=d" (tmp
)
46 : "a" (page
), "0" (sp
),
47 "1" ((PAGE_SIZE
- 16) / 16 - 1));
51 #define clear_page(page) memset((page), 0, PAGE_SIZE)
52 #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
55 #define clear_user_page(addr, vaddr, page) \
56 do { clear_page(addr); \
57 flush_dcache_page(page); \
59 #define copy_user_page(to, from, vaddr, page) \
60 do { copy_page(to, from); \
61 flush_dcache_page(page); \
64 extern unsigned long m68k_memoffset
;
68 #define WANT_PAGE_VIRTUAL
70 static inline unsigned long ___pa(void *vaddr
)
77 : "0" (vaddr
), "i" (m68k_fixup_memoffset
));
80 #define __pa(vaddr) ___pa((void *)(long)(vaddr))
81 static inline void *__va(unsigned long paddr
)
88 : "0" (paddr
), "i" (m68k_fixup_memoffset
));
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
)
100 return (x
-PAGE_OFFSET
);
102 return (x
+0x2000000);
105 static inline void *__va(unsigned long x
)
111 return (void *)(x
+PAGE_OFFSET
);
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])
131 extern struct pglist_data
*pg_data_table
[];
133 static inline __attribute_const__
int __virt_to_node_shift(void)
141 : "i" (m68k_fixup_vnode_shift
));
145 #define __virt_to_node(addr) (pg_data_table[(unsigned long)(addr) >> __virt_to_node_shift()])
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 */