GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / score / include / asm / pgtable.h
blobccf38f06c57d78110e14cd21a0e3984c3c52b52d
1 #ifndef _ASM_SCORE_PGTABLE_H
2 #define _ASM_SCORE_PGTABLE_H
4 #include <linux/const.h>
5 #include <asm-generic/pgtable-nopmd.h>
7 #include <asm/fixmap.h>
8 #include <asm/setup.h>
9 #include <asm/pgtable-bits.h>
11 extern void load_pgd(unsigned long pg_dir);
12 extern pte_t invalid_pte_table[PAGE_SIZE/sizeof(pte_t)];
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))
20 * Entries per page directory level: we use two-level, so
21 * we don't really have any PUD/PMD directory physically.
23 #define PGD_ORDER 0
24 #define PTE_ORDER 0
26 #define PTRS_PER_PGD 1024
27 #define PTRS_PER_PTE 1024
29 #define USER_PTRS_PER_PGD (0x80000000UL/PGDIR_SIZE)
30 #define FIRST_USER_ADDRESS 0
32 #define VMALLOC_START (0xc0000000UL)
34 #define PKMAP_BASE (0xfd000000UL)
36 #define VMALLOC_END (FIXADDR_START - 2*PAGE_SIZE)
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))
46 * Empty pgd/pmd entries point to the invalid_pte_table.
48 static inline int pmd_none(pmd_t pmd)
50 return pmd_val(pmd) == (unsigned long) invalid_pte_table;
53 #define pmd_bad(pmd) (pmd_val(pmd) & ~PAGE_MASK)
55 static inline int pmd_present(pmd_t pmd)
57 return pmd_val(pmd) != (unsigned long) invalid_pte_table;
60 static inline void pmd_clear(pmd_t *pmdp)
62 pmd_val(*pmdp) = ((unsigned long) invalid_pte_table);
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))
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))
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))
78 /* to find an entry in a page-table-directory */
79 #define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr))
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))
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))
97 * Bits 9(_PAGE_PRESENT) and 10(_PAGE_FILE)are taken,
98 * split up 30 bits of offset into this range:
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})
109 #define pmd_phys(pmd) __pa((void *)pmd_val(pmd))
110 #define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
111 #define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot)
112 static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
114 #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
115 #define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
116 #define pte_clear(mm, addr, xp) \
117 do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
119 #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
120 remap_pfn_range(vma, vaddr, pfn, size, prot)
123 * The "pgd_xxx()" functions here are trivial for a folded two-level
124 * setup: the pgd is never bad, and a pmd always exists (as it's folded
125 * into the pgd entry)
127 #define pgd_present(pgd) (1)
128 #define pgd_none(pgd) (0)
129 #define pgd_bad(pgd) (0)
130 #define pgd_clear(pgdp) do { } while (0)
132 #define kern_addr_valid(addr) (1)
133 #define pmd_page_vaddr(pmd) pmd_val(pmd)
135 #define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))
136 #define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
138 #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_CACHE)
139 #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
140 _PAGE_CACHE)
141 #define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_CACHE)
142 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_CACHE)
143 #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \
144 _PAGE_GLOBAL | _PAGE_CACHE)
145 #define PAGE_KERNEL_UNCACHED __pgprot(_PAGE_PRESENT | __READABLE | \
146 __WRITEABLE | _PAGE_GLOBAL & ~_PAGE_CACHE)
148 #define __P000 PAGE_NONE
149 #define __P001 PAGE_READONLY
150 #define __P010 PAGE_COPY
151 #define __P011 PAGE_COPY
152 #define __P100 PAGE_READONLY
153 #define __P101 PAGE_READONLY
154 #define __P110 PAGE_COPY
155 #define __P111 PAGE_COPY
157 #define __S000 PAGE_NONE
158 #define __S001 PAGE_READONLY
159 #define __S010 PAGE_SHARED
160 #define __S011 PAGE_SHARED
161 #define __S100 PAGE_READONLY
162 #define __S101 PAGE_READONLY
163 #define __S110 PAGE_SHARED
164 #define __S111 PAGE_SHARED
166 #define pgprot_noncached pgprot_noncached
168 static inline pgprot_t pgprot_noncached(pgprot_t _prot)
170 unsigned long prot = pgprot_val(_prot);
172 prot = (prot & ~_CACHE_MASK);
174 return __pgprot(prot);
177 #define __swp_type(x) ((x).val & 0x1f)
178 #define __swp_offset(x) ((x).val >> 11)
179 #define __swp_entry(type, offset) ((swp_entry_t){(type) | ((offset) << 11)})
181 extern unsigned long empty_zero_page;
182 extern unsigned long zero_page_mask;
184 #define ZERO_PAGE(vaddr) \
185 (virt_to_page((void *)(empty_zero_page + \
186 (((unsigned long)(vaddr)) & zero_page_mask))))
188 #define pgtable_cache_init() do {} while (0)
190 #define arch_enter_lazy_cpu_mode() do {} while (0)
192 static inline int pte_write(pte_t pte)
194 return pte_val(pte) & _PAGE_WRITE;
197 static inline int pte_dirty(pte_t pte)
199 return pte_val(pte) & _PAGE_MODIFIED;
202 static inline int pte_young(pte_t pte)
204 return pte_val(pte) & _PAGE_ACCESSED;
207 static inline int pte_file(pte_t pte)
209 return pte_val(pte) & _PAGE_FILE;
212 #define pte_special(pte) (0)
214 static inline pte_t pte_wrprotect(pte_t pte)
216 pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
217 return pte;
220 static inline pte_t pte_mkclean(pte_t pte)
222 pte_val(pte) &= ~(_PAGE_MODIFIED|_PAGE_SILENT_WRITE);
223 return pte;
226 static inline pte_t pte_mkold(pte_t pte)
228 pte_val(pte) &= ~(_PAGE_ACCESSED|_PAGE_SILENT_READ);
229 return pte;
232 static inline pte_t pte_mkwrite(pte_t pte)
234 pte_val(pte) |= _PAGE_WRITE;
235 if (pte_val(pte) & _PAGE_MODIFIED)
236 pte_val(pte) |= _PAGE_SILENT_WRITE;
237 return pte;
240 static inline pte_t pte_mkdirty(pte_t pte)
242 pte_val(pte) |= _PAGE_MODIFIED;
243 if (pte_val(pte) & _PAGE_WRITE)
244 pte_val(pte) |= _PAGE_SILENT_WRITE;
245 return pte;
248 static inline pte_t pte_mkyoung(pte_t pte)
250 pte_val(pte) |= _PAGE_ACCESSED;
251 if (pte_val(pte) & _PAGE_READ)
252 pte_val(pte) |= _PAGE_SILENT_READ;
253 return pte;
256 #define set_pmd(pmdptr, pmdval) \
257 do { *(pmdptr) = (pmdval); } while (0)
258 #define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
260 extern unsigned long pgd_current;
261 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
262 extern void paging_init(void);
264 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
266 return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
269 extern void __update_tlb(struct vm_area_struct *vma,
270 unsigned long address, pte_t pte);
271 extern void __update_cache(struct vm_area_struct *vma,
272 unsigned long address, pte_t pte);
274 static inline void update_mmu_cache(struct vm_area_struct *vma,
275 unsigned long address, pte_t *ptep)
277 pte_t pte = *ptep;
278 __update_tlb(vma, address, pte);
279 __update_cache(vma, address, pte);
282 #ifndef __ASSEMBLY__
283 #include <asm-generic/pgtable.h>
285 void setup_memory(void);
286 #endif /* __ASSEMBLY__ */
288 #endif /* _ASM_SCORE_PGTABLE_H */