aboutsummaryrefslogtreecommitdiffstats
path: root/arch/score/include/asm/pgtable.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/score/include/asm/pgtable.h')
-rw-r--r--arch/score/include/asm/pgtable.h267
1 files changed, 267 insertions, 0 deletions
diff --git a/arch/score/include/asm/pgtable.h b/arch/score/include/asm/pgtable.h
new file mode 100644
index 000000000000..0f7177a42205
--- /dev/null
+++ b/arch/score/include/asm/pgtable.h
@@ -0,0 +1,267 @@
1#ifndef _ASM_SCORE_PGTABLE_H
2#define _ASM_SCORE_PGTABLE_H
3
4#include <linux/const.h>
5#include <asm-generic/pgtable-nopmd.h>
6
7#include <asm/fixmap.h>
8#include <asm/setup.h>
9#include <asm/pgtable-bits.h>
10
11extern void load_pgd(unsigned long pg_dir);
12extern pte_t invalid_pte_table[PAGE_SIZE/sizeof(pte_t)];
13
14/* PGDIR_SHIFT determines what a third-level page table entry can map */
15#define PGDIR_SHIFT 22
16#define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT)
17#define PGDIR_MASK (~(PGDIR_SIZE - 1))
18
19/*
20 * Entries per page directory level: we use two-level, so
21 * we don't really have any PUD/PMD directory physically.
22 */
23#define PGD_ORDER 0
24#define PTE_ORDER 0
25
26#define PTRS_PER_PGD 1024
27#define PTRS_PER_PTE 1024
28
29#define USER_PTRS_PER_PGD (0x80000000UL/PGDIR_SIZE)
30#define FIRST_USER_ADDRESS 0
31
32#define VMALLOC_START (0xc0000000UL)
33
34#define PKMAP_BASE (0xfd000000UL)
35
36#define VMALLOC_END (FIXADDR_START - 2*PAGE_SIZE)
37
38#define pte_ERROR(e) \
39 printk(KERN_ERR "%s:%d: bad pte %08lx.\n", \
40 __FILE__, __LINE__, pte_val(e))
41#define pgd_ERROR(e) \
42 printk(KERN_ERR "%s:%d: bad pgd %08lx.\n", \
43 __FILE__, __LINE__, pgd_val(e))
44
45/*
46 * Empty pgd/pmd entries point to the invalid_pte_table.
47 */
48static inline int pmd_none(pmd_t pmd)
49{
50 return pmd_val(pmd) == (unsigned long) invalid_pte_table;
51}
52
53#define pmd_bad(pmd) (pmd_val(pmd) & ~PAGE_MASK)
54
55static inline int pmd_present(pmd_t pmd)
56{
57 return pmd_val(pmd) != (unsigned long) invalid_pte_table;
58}
59
60static inline void pmd_clear(pmd_t *pmdp)
61{
62 pmd_val(*pmdp) = ((unsigned long) invalid_pte_table);
63}
64
65#define pte_page(x) pfn_to_page(pte_pfn(x))
66#define pte_pfn(x) ((unsigned long)((x).pte >> PAGE_SHIFT))
67#define pfn_pte(pfn, prot) \
68 __pte(((unsigned long long)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
69
70#define __pgd_offset(address) pgd_index(address)
71#define __pud_offset(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
72#define __pmd_offset(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
73
74/* to find an entry in a kernel page-table-directory */
75#define pgd_offset_k(address) pgd_offset(&init_mm, address)
76#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
77
78/* to find an entry in a page-table-directory */
79#define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr))
80
81/* Find an entry in the third-level page table.. */
82#define __pte_offset(address) \
83 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
84#define pte_offset(dir, address) \
85 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
86#define pte_offset_kernel(dir, address) \
87 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
88
89#define pte_offset_map(dir, address) \
90 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
91#define pte_offset_map_nested(dir, address) \
92 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
93#define pte_unmap(pte) ((void)(pte))
94#define pte_unmap_nested(pte) ((void)(pte))
95
96/*
97 * Bits 9(_PAGE_PRESENT) and 10(_PAGE_FILE)are taken,
98 * split up 30 bits of offset into this range:
99 */
100#define PTE_FILE_MAX_BITS 30
101#define pte_to_pgoff(_pte) \
102 (((_pte).pte & 0x1ff) | (((_pte).pte >> 11) << 9))
103#define pgoff_to_pte(off) \
104 ((pte_t) {((off) & 0x1ff) | (((off) >> 9) << 11) | _PAGE_FILE})
105#define __pte_to_swp_entry(pte) \
106 ((swp_entry_t) { pte_val(pte)})
107#define __swp_entry_to_pte(x) ((pte_t) {(x).val})
108
109#define __P000 __pgprot(0)
110#define __P001 __pgprot(0)
111#define __P010 __pgprot(0)
112#define __P011 __pgprot(0)
113#define __P100 __pgprot(0)
114#define __P101 __pgprot(0)
115#define __P110 __pgprot(0)
116#define __P111 __pgprot(0)
117
118#define __S000 __pgprot(0)
119#define __S001 __pgprot(0)
120#define __S010 __pgprot(0)
121#define __S011 __pgprot(0)
122#define __S100 __pgprot(0)
123#define __S101 __pgprot(0)
124#define __S110 __pgprot(0)
125#define __S111 __pgprot(0)
126
127#define pmd_page(pmd) virt_to_page(__va(pmd_val(pmd)))
128#define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot)
129static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
130
131#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
132#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
133#define pte_clear(mm, addr, xp) \
134 do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
135
136#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
137 remap_pfn_range(vma, vaddr, pfn, size, prot)
138
139#define pgd_present(pgd) (1) /* pages are always present on non MMU */
140#define pgd_none(pgd) (0)
141#define pgd_bad(pgd) (0)
142#define pgd_clear(pgdp)
143
144#define kern_addr_valid(addr) (1)
145#define pmd_offset(a, b) ((void *) 0)
146#define pmd_page_vaddr(pmd) pmd_val(pmd)
147
148#define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))
149#define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
150
151#define pud_offset(pgd, address) ((pud_t *) pgd)
152
153#define PAGE_NONE __pgprot(0) /* these mean nothing to non MMU */
154#define PAGE_SHARED __pgprot(0) /* these mean nothing to non MMU */
155#define PAGE_COPY __pgprot(0) /* these mean nothing to non MMU */
156#define PAGE_READONLY __pgprot(0) /* these mean nothing to non MMU */
157#define PAGE_KERNEL __pgprot(0) /* these mean nothing to non MMU */
158
159#define pgprot_noncached(x) (x)
160
161#define __swp_type(x) (0)
162#define __swp_offset(x) (0)
163#define __swp_entry(typ, off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
164
165#define ZERO_PAGE(vaddr) ({ BUG(); NULL; })
166
167#define swapper_pg_dir ((pgd_t *) NULL)
168
169#define pgtable_cache_init() do {} while (0)
170
171#define arch_enter_lazy_cpu_mode() do {} while (0)
172
173static inline int pte_write(pte_t pte)
174{
175 return pte_val(pte) & _PAGE_WRITE;
176}
177
178static inline int pte_dirty(pte_t pte)
179{
180 return pte_val(pte) & _PAGE_MODIFIED;
181}
182
183static inline int pte_young(pte_t pte)
184{
185 return pte_val(pte) & _PAGE_ACCESSED;
186}
187
188static inline int pte_file(pte_t pte)
189{
190 return pte_val(pte) & _PAGE_FILE;
191}
192
193#define pte_special(pte) (0)
194
195static inline pte_t pte_wrprotect(pte_t pte)
196{
197 pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
198 return pte;
199}
200
201static inline pte_t pte_mkclean(pte_t pte)
202{
203 pte_val(pte) &= ~(_PAGE_MODIFIED|_PAGE_SILENT_WRITE);
204 return pte;
205}
206
207static inline pte_t pte_mkold(pte_t pte)
208{
209 pte_val(pte) &= ~(_PAGE_ACCESSED|_PAGE_SILENT_READ);
210 return pte;
211}
212
213static inline pte_t pte_mkwrite(pte_t pte)
214{
215 pte_val(pte) |= _PAGE_WRITE;
216 if (pte_val(pte) & _PAGE_MODIFIED)
217 pte_val(pte) |= _PAGE_SILENT_WRITE;
218 return pte;
219}
220
221static inline pte_t pte_mkdirty(pte_t pte)
222{
223 pte_val(pte) |= _PAGE_MODIFIED;
224 if (pte_val(pte) & _PAGE_WRITE)
225 pte_val(pte) |= _PAGE_SILENT_WRITE;
226 return pte;
227}
228
229static inline pte_t pte_mkyoung(pte_t pte)
230{
231 pte_val(pte) |= _PAGE_ACCESSED;
232 if (pte_val(pte) & _PAGE_READ)
233 pte_val(pte) |= _PAGE_SILENT_READ;
234 return pte;
235}
236
237#define set_pmd(pmdptr, pmdval) \
238 do { *(pmdptr) = (pmdval); } while (0)
239#define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
240
241extern unsigned long pgd_current;
242extern void paging_init(void);
243
244static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
245{
246 return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
247}
248
249extern void __update_tlb(struct vm_area_struct *vma,
250 unsigned long address, pte_t pte);
251extern void __update_cache(struct vm_area_struct *vma,
252 unsigned long address, pte_t pte);
253
254static inline void update_mmu_cache(struct vm_area_struct *vma,
255 unsigned long address, pte_t pte)
256{
257 __update_tlb(vma, address, pte);
258 __update_cache(vma, address, pte);
259}
260
261#ifndef __ASSEMBLY__
262#include <asm-generic/pgtable.h>
263
264void setup_memory(void);
265#endif /* __ASSEMBLY__ */
266
267#endif /* _ASM_SCORE_PGTABLE_H */