4 #include <linux/const.h>
6 /* PAGE_SHIFT determines the page size */
8 #define PAGE_SHIFT (12)
10 #define PAGE_SHIFT (13)
12 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
13 #define PAGE_MASK (~(PAGE_SIZE-1))
15 #include <asm/setup.h>
18 #define THREAD_SIZE (8192)
20 #define THREAD_SIZE PAGE_SIZE
25 #include <linux/compiler.h>
27 #include <asm/module.h>
29 #define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
30 #define free_user_page(page, addr) free_page(addr)
33 * We don't need to check for alignment etc.
35 #ifdef CPU_M68040_OR_M68060_ONLY
36 static inline void copy_page(void *to
, void *from
)
40 __asm__
__volatile__("1:\t"
42 "move16 %1@+,%0@+\n\t"
43 "move16 %1@+,%0@+\n\t"
46 : "=a" (to
), "=a" (from
), "=d" (tmp
)
47 : "0" (to
), "1" (from
) , "2" (PAGE_SIZE
/ 32 - 1)
51 static inline void clear_page(void *page
)
54 unsigned long *sp
= page
;
61 __asm__
__volatile__("1:\t"
63 "move16 %2@+,%0@+\n\t"
68 : "=a" (sp
), "=d" (tmp
)
69 : "a" (page
), "0" (sp
),
70 "1" ((PAGE_SIZE
- 16) / 16 - 1));
74 #define clear_page(page) memset((page), 0, PAGE_SIZE)
75 #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
78 #define clear_user_page(addr, vaddr, page) \
79 do { clear_page(addr); \
80 flush_dcache_page(page); \
82 #define copy_user_page(to, from, vaddr, page) \
83 do { copy_page(to, from); \
84 flush_dcache_page(page); \
88 * These are used to make use of C type-checking..
90 typedef struct { unsigned long pte
; } pte_t
;
91 typedef struct { unsigned long pmd
[16]; } pmd_t
;
92 typedef struct { unsigned long pgd
; } pgd_t
;
93 typedef struct { unsigned long pgprot
; } pgprot_t
;
95 #define pte_val(x) ((x).pte)
96 #define pmd_val(x) ((&x)->pmd[0])
97 #define pgd_val(x) ((x).pgd)
98 #define pgprot_val(x) ((x).pgprot)
100 #define __pte(x) ((pte_t) { (x) } )
101 #define __pmd(x) ((pmd_t) { (x) } )
102 #define __pgd(x) ((pgd_t) { (x) } )
103 #define __pgprot(x) ((pgprot_t) { (x) } )
105 /* to align the pointer to the (next) page boundary */
106 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
108 #endif /* !__ASSEMBLY__ */
110 #include <asm/page_offset.h>
112 #define PAGE_OFFSET (PAGE_OFFSET_RAW)
116 extern unsigned long m68k_memoffset
;
120 #define WANT_PAGE_VIRTUAL
122 static inline unsigned long ___pa(void *vaddr
)
127 m68k_fixup(%c2
, 1b
+2)
129 : "0" (vaddr
), "i" (m68k_fixup_memoffset
));
132 #define __pa(vaddr) ___pa((void *)(vaddr))
133 static inline void *__va(unsigned long paddr
)
138 m68k_fixup(%c2
, 1b
+2)
140 : "0" (paddr
), "i" (m68k_fixup_memoffset
));
144 #else /* !CONFIG_SUN3 */
145 /* This #define is a horrible hack to suppress lots of warnings. --m */
146 #define __pa(x) ___pa((unsigned long)(x))
147 static inline unsigned long ___pa(unsigned long x
)
152 return (x
-PAGE_OFFSET
);
154 return (x
+0x2000000);
157 static inline void *__va(unsigned long x
)
163 return (void *)(x
+PAGE_OFFSET
);
165 return (void *)(x
-0x2000000);
167 #endif /* CONFIG_SUN3 */
170 * NOTE: virtual isn't really correct, actually it should be the offset into the
171 * memory node, but we have no highmem, so that works for now.
172 * TODO: implement (fast) pfn<->pgdat_idx conversion functions, this makes lots
173 * of the shifts unnecessary.
175 #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
176 #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
178 extern int m68k_virt_to_node_shift
;
180 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
181 #define __virt_to_node(addr) (&pg_data_map[0])
183 extern struct pglist_data
*pg_data_table
[];
185 static inline __attribute_const__
int __virt_to_node_shift(void)
193 : "i" (m68k_fixup_vnode_shift
));
197 #define __virt_to_node(addr) (pg_data_table[(unsigned long)(addr) >> __virt_to_node_shift()])
200 #define virt_to_page(addr) ({ \
201 pfn_to_page(virt_to_pfn(addr)); \
203 #define page_to_virt(page) ({ \
204 pfn_to_virt(page_to_pfn(page)); \
207 #define pfn_to_page(pfn) ({ \
208 unsigned long __pfn = (pfn); \
209 struct pglist_data *pgdat; \
210 pgdat = __virt_to_node((unsigned long)pfn_to_virt(__pfn)); \
211 pgdat->node_mem_map + (__pfn - pgdat->node_start_pfn); \
213 #define page_to_pfn(_page) ({ \
214 struct page *__p = (_page); \
215 struct pglist_data *pgdat; \
216 pgdat = &pg_data_map[page_to_nid(__p)]; \
217 ((__p) - pgdat->node_mem_map) + pgdat->node_start_pfn; \
220 #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
221 #define pfn_valid(pfn) virt_addr_valid(pfn_to_virt(pfn))
223 #endif /* __ASSEMBLY__ */
225 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
226 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
228 #include <asm-generic/page.h>
230 #endif /* _M68K_PAGE_H */