diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-m68k/page.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-m68k/page.h')
-rw-r--r-- | include/asm-m68k/page.h | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/include/asm-m68k/page.h b/include/asm-m68k/page.h new file mode 100644 index 000000000000..99a516709210 --- /dev/null +++ b/include/asm-m68k/page.h | |||
@@ -0,0 +1,195 @@ | |||
1 | #ifndef _M68K_PAGE_H | ||
2 | #define _M68K_PAGE_H | ||
3 | |||
4 | #include <linux/config.h> | ||
5 | |||
6 | /* PAGE_SHIFT determines the page size */ | ||
7 | #ifndef CONFIG_SUN3 | ||
8 | #define PAGE_SHIFT (12) | ||
9 | #else | ||
10 | #define PAGE_SHIFT (13) | ||
11 | #endif | ||
12 | #ifdef __ASSEMBLY__ | ||
13 | #define PAGE_SIZE (1 << PAGE_SHIFT) | ||
14 | #else | ||
15 | #define PAGE_SIZE (1UL << PAGE_SHIFT) | ||
16 | #endif | ||
17 | #define PAGE_MASK (~(PAGE_SIZE-1)) | ||
18 | |||
19 | #ifdef __KERNEL__ | ||
20 | |||
21 | #include <asm/setup.h> | ||
22 | |||
23 | #if PAGE_SHIFT < 13 | ||
24 | #define THREAD_SIZE (8192) | ||
25 | #else | ||
26 | #define THREAD_SIZE PAGE_SIZE | ||
27 | #endif | ||
28 | |||
29 | #ifndef __ASSEMBLY__ | ||
30 | |||
31 | #define get_user_page(vaddr) __get_free_page(GFP_KERNEL) | ||
32 | #define free_user_page(page, addr) free_page(addr) | ||
33 | |||
34 | /* | ||
35 | * We don't need to check for alignment etc. | ||
36 | */ | ||
37 | #ifdef CPU_M68040_OR_M68060_ONLY | ||
38 | static inline void copy_page(void *to, void *from) | ||
39 | { | ||
40 | unsigned long tmp; | ||
41 | |||
42 | __asm__ __volatile__("1:\t" | ||
43 | ".chip 68040\n\t" | ||
44 | "move16 %1@+,%0@+\n\t" | ||
45 | "move16 %1@+,%0@+\n\t" | ||
46 | ".chip 68k\n\t" | ||
47 | "dbra %2,1b\n\t" | ||
48 | : "=a" (to), "=a" (from), "=d" (tmp) | ||
49 | : "0" (to), "1" (from) , "2" (PAGE_SIZE / 32 - 1) | ||
50 | ); | ||
51 | } | ||
52 | |||
53 | static inline void clear_page(void *page) | ||
54 | { | ||
55 | unsigned long tmp; | ||
56 | unsigned long *sp = page; | ||
57 | |||
58 | *sp++ = 0; | ||
59 | *sp++ = 0; | ||
60 | *sp++ = 0; | ||
61 | *sp++ = 0; | ||
62 | |||
63 | __asm__ __volatile__("1:\t" | ||
64 | ".chip 68040\n\t" | ||
65 | "move16 %2@+,%0@+\n\t" | ||
66 | ".chip 68k\n\t" | ||
67 | "subqw #8,%2\n\t" | ||
68 | "subqw #8,%2\n\t" | ||
69 | "dbra %1,1b\n\t" | ||
70 | : "=a" (sp), "=d" (tmp) | ||
71 | : "a" (page), "0" (sp), | ||
72 | "1" ((PAGE_SIZE - 16) / 16 - 1)); | ||
73 | } | ||
74 | |||
75 | #else | ||
76 | #define clear_page(page) memset((page), 0, PAGE_SIZE) | ||
77 | #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE) | ||
78 | #endif | ||
79 | |||
80 | #define clear_user_page(addr, vaddr, page) \ | ||
81 | do { clear_page(addr); \ | ||
82 | flush_dcache_page(page); \ | ||
83 | } while (0) | ||
84 | #define copy_user_page(to, from, vaddr, page) \ | ||
85 | do { copy_page(to, from); \ | ||
86 | flush_dcache_page(page); \ | ||
87 | } while (0) | ||
88 | |||
89 | /* | ||
90 | * These are used to make use of C type-checking.. | ||
91 | */ | ||
92 | typedef struct { unsigned long pte; } pte_t; | ||
93 | typedef struct { unsigned long pmd[16]; } pmd_t; | ||
94 | typedef struct { unsigned long pgd; } pgd_t; | ||
95 | typedef struct { unsigned long pgprot; } pgprot_t; | ||
96 | |||
97 | #define pte_val(x) ((x).pte) | ||
98 | #define pmd_val(x) ((&x)->pmd[0]) | ||
99 | #define pgd_val(x) ((x).pgd) | ||
100 | #define pgprot_val(x) ((x).pgprot) | ||
101 | |||
102 | #define __pte(x) ((pte_t) { (x) } ) | ||
103 | #define __pmd(x) ((pmd_t) { (x) } ) | ||
104 | #define __pgd(x) ((pgd_t) { (x) } ) | ||
105 | #define __pgprot(x) ((pgprot_t) { (x) } ) | ||
106 | |||
107 | /* to align the pointer to the (next) page boundary */ | ||
108 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) | ||
109 | |||
110 | /* Pure 2^n version of get_order */ | ||
111 | static inline int get_order(unsigned long size) | ||
112 | { | ||
113 | int order; | ||
114 | |||
115 | size = (size-1) >> (PAGE_SHIFT-1); | ||
116 | order = -1; | ||
117 | do { | ||
118 | size >>= 1; | ||
119 | order++; | ||
120 | } while (size); | ||
121 | return order; | ||
122 | } | ||
123 | |||
124 | #endif /* !__ASSEMBLY__ */ | ||
125 | |||
126 | #include <asm/page_offset.h> | ||
127 | |||
128 | #define PAGE_OFFSET (PAGE_OFFSET_RAW) | ||
129 | |||
130 | #ifndef __ASSEMBLY__ | ||
131 | |||
132 | #ifndef CONFIG_SUN3 | ||
133 | |||
134 | #define WANT_PAGE_VIRTUAL | ||
135 | #ifdef CONFIG_SINGLE_MEMORY_CHUNK | ||
136 | extern unsigned long m68k_memoffset; | ||
137 | |||
138 | #define __pa(vaddr) ((unsigned long)(vaddr)+m68k_memoffset) | ||
139 | #define __va(paddr) ((void *)((unsigned long)(paddr)-m68k_memoffset)) | ||
140 | #else | ||
141 | #define __pa(vaddr) virt_to_phys((void *)vaddr) | ||
142 | #define __va(paddr) phys_to_virt((unsigned long)paddr) | ||
143 | #endif | ||
144 | |||
145 | #else /* !CONFIG_SUN3 */ | ||
146 | /* This #define is a horrible hack to suppress lots of warnings. --m */ | ||
147 | #define __pa(x) ___pa((unsigned long)x) | ||
148 | static inline unsigned long ___pa(unsigned long x) | ||
149 | { | ||
150 | if(x == 0) | ||
151 | return 0; | ||
152 | if(x >= PAGE_OFFSET) | ||
153 | return (x-PAGE_OFFSET); | ||
154 | else | ||
155 | return (x+0x2000000); | ||
156 | } | ||
157 | |||
158 | static inline void *__va(unsigned long x) | ||
159 | { | ||
160 | if(x == 0) | ||
161 | return (void *)0; | ||
162 | |||
163 | if(x < 0x2000000) | ||
164 | return (void *)(x+PAGE_OFFSET); | ||
165 | else | ||
166 | return (void *)(x-0x2000000); | ||
167 | } | ||
168 | #endif /* CONFIG_SUN3 */ | ||
169 | |||
170 | /* | ||
171 | * NOTE: virtual isn't really correct, actually it should be the offset into the | ||
172 | * memory node, but we have no highmem, so that works for now. | ||
173 | * TODO: implement (fast) pfn<->pgdat_idx conversion functions, this makes lots | ||
174 | * of the shifts unnecessary. | ||
175 | */ | ||
176 | #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) | ||
177 | #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) | ||
178 | |||
179 | #define virt_to_page(kaddr) (mem_map + (((unsigned long)(kaddr)-PAGE_OFFSET) >> PAGE_SHIFT)) | ||
180 | #define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) | ||
181 | |||
182 | #define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn)) | ||
183 | #define page_to_pfn(page) virt_to_pfn(page_to_virt(page)) | ||
184 | |||
185 | #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory) | ||
186 | #define pfn_valid(pfn) virt_addr_valid(pfn_to_virt(pfn)) | ||
187 | |||
188 | #endif /* __ASSEMBLY__ */ | ||
189 | |||
190 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ | ||
191 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) | ||
192 | |||
193 | #endif /* __KERNEL__ */ | ||
194 | |||
195 | #endif /* _M68K_PAGE_H */ | ||