1 #ifndef _M68K_PAGE_MM_H
2 #define _M68K_PAGE_MM_H
6 #include <linux/compiler.h>
7 #include <asm/module.h>
9 #define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
10 #define free_user_page(page, addr) free_page(addr)
13 * We don't need to check for alignment etc.
15 #ifdef CPU_M68040_OR_M68060_ONLY
16 static inline void copy_page(void *to
, void *from
)
20 __asm__
__volatile__("1:\t"
22 "move16 %1@+,%0@+\n\t"
23 "move16 %1@+,%0@+\n\t"
26 : "=a" (to
), "=a" (from
), "=d" (tmp
)
27 : "0" (to
), "1" (from
) , "2" (PAGE_SIZE
/ 32 - 1)
31 static inline void clear_page(void *page
)
34 unsigned long *sp
= page
;
41 __asm__
__volatile__("1:\t"
43 "move16 %2@+,%0@+\n\t"
48 : "=a" (sp
), "=d" (tmp
)
49 : "a" (page
), "0" (sp
),
50 "1" ((PAGE_SIZE
- 16) / 16 - 1));
54 #define clear_page(page) memset((page), 0, PAGE_SIZE)
55 #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
58 #define clear_user_page(addr, vaddr, page) \
59 do { clear_page(addr); \
60 flush_dcache_page(page); \
62 #define copy_user_page(to, from, vaddr, page) \
63 do { copy_page(to, from); \
64 flush_dcache_page(page); \
67 extern unsigned long m68k_memoffset
;
71 #define WANT_PAGE_VIRTUAL
73 static inline unsigned long ___pa(void *vaddr
)
80 : "0" (vaddr
), "i" (m68k_fixup_memoffset
));
83 #define __pa(vaddr) ___pa((void *)(long)(vaddr))
84 static inline void *__va(unsigned long paddr
)
91 : "0" (paddr
), "i" (m68k_fixup_memoffset
));
95 #else /* !CONFIG_SUN3 */
96 /* This #define is a horrible hack to suppress lots of warnings. --m */
97 #define __pa(x) ___pa((unsigned long)(x))
98 static inline unsigned long ___pa(unsigned long x
)
103 return (x
-PAGE_OFFSET
);
105 return (x
+0x2000000);
108 static inline void *__va(unsigned long x
)
114 return (void *)(x
+PAGE_OFFSET
);
116 return (void *)(x
-0x2000000);
118 #endif /* CONFIG_SUN3 */
121 * NOTE: virtual isn't really correct, actually it should be the offset into the
122 * memory node, but we have no highmem, so that works for now.
123 * TODO: implement (fast) pfn<->pgdat_idx conversion functions, this makes lots
124 * of the shifts unnecessary.
126 #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
127 #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
129 extern int m68k_virt_to_node_shift
;
131 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
132 #define __virt_to_node(addr) (&pg_data_map[0])
134 extern struct pglist_data
*pg_data_table
[];
136 static inline __attribute_const__
int __virt_to_node_shift(void)
144 : "i" (m68k_fixup_vnode_shift
));
148 #define __virt_to_node(addr) (pg_data_table[(unsigned long)(addr) >> __virt_to_node_shift()])
151 #define virt_to_page(addr) ({ \
152 pfn_to_page(virt_to_pfn(addr)); \
154 #define page_to_virt(page) ({ \
155 pfn_to_virt(page_to_pfn(page)); \
158 #define pfn_to_page(pfn) ({ \
159 unsigned long __pfn = (pfn); \
160 struct pglist_data *pgdat; \
161 pgdat = __virt_to_node((unsigned long)pfn_to_virt(__pfn)); \
162 pgdat->node_mem_map + (__pfn - pgdat->node_start_pfn); \
164 #define page_to_pfn(_page) ({ \
165 const struct page *__p = (_page); \
166 struct pglist_data *pgdat; \
167 pgdat = &pg_data_map[page_to_nid(__p)]; \
168 ((__p) - pgdat->node_mem_map) + pgdat->node_start_pfn; \
171 #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
172 #define pfn_valid(pfn) virt_addr_valid(pfn_to_virt(pfn))
174 #endif /* __ASSEMBLY__ */
176 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
177 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
179 #endif /* _M68K_PAGE_MM_H */