~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/score/include/asm/pgtable.h

Version: ~ [ linux-5.9-rc6 ] ~ [ linux-5.8.10 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.66 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.146 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.198 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.236 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.236 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 
 11 extern void load_pgd(unsigned long pg_dir);
 12 extern 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  */
 48 static 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 
 55 static inline int pmd_present(pmd_t pmd)
 56 {
 57         return pmd_val(pmd) != (unsigned long) invalid_pte_table;
 58 }
 59 
 60 static 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_unmap(pte) ((void)(pte))
 92 
 93 /*
 94  * Bits 9(_PAGE_PRESENT) and 10(_PAGE_FILE)are taken,
 95  * split up 30 bits of offset into this range:
 96  */
 97 #define PTE_FILE_MAX_BITS       30
 98 #define pte_to_pgoff(_pte)              \
 99         (((_pte).pte & 0x1ff) | (((_pte).pte >> 11) << 9))
100 #define pgoff_to_pte(off)               \
101         ((pte_t) {((off) & 0x1ff) | (((off) >> 9) << 11) | _PAGE_FILE})
102 #define __pte_to_swp_entry(pte)         \
103         ((swp_entry_t) { pte_val(pte)})
104 #define __swp_entry_to_pte(x)   ((pte_t) {(x).val})
105 
106 #define pmd_phys(pmd)           __pa((void *)pmd_val(pmd))
107 #define pmd_page(pmd)           (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
108 #define mk_pte(page, prot)      pfn_pte(page_to_pfn(page), prot)
109 static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
110 
111 #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
112 #define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
113 #define pte_clear(mm, addr, xp)         \
114         do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
115 
116 /*
117  * The "pgd_xxx()" functions here are trivial for a folded two-level
118  * setup: the pgd is never bad, and a pmd always exists (as it's folded
119  * into the pgd entry)
120  */
121 #define pgd_present(pgd)        (1)
122 #define pgd_none(pgd)           (0)
123 #define pgd_bad(pgd)            (0)
124 #define pgd_clear(pgdp)         do { } while (0)
125 
126 #define kern_addr_valid(addr)   (1)
127 #define pmd_page_vaddr(pmd)     pmd_val(pmd)
128 
129 #define pte_none(pte)           (!(pte_val(pte) & ~_PAGE_GLOBAL))
130 #define pte_present(pte)        (pte_val(pte) & _PAGE_PRESENT)
131 
132 #define PAGE_NONE       __pgprot(_PAGE_PRESENT | _PAGE_CACHE)
133 #define PAGE_SHARED     __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
134                                 _PAGE_CACHE)
135 #define PAGE_COPY       __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_CACHE)
136 #define PAGE_READONLY   __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_CACHE)
137 #define PAGE_KERNEL     __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \
138                                 _PAGE_GLOBAL | _PAGE_CACHE)
139 #define PAGE_KERNEL_UNCACHED __pgprot(_PAGE_PRESENT | __READABLE | \
140                                 __WRITEABLE | _PAGE_GLOBAL & ~_PAGE_CACHE)
141 
142 #define __P000  PAGE_NONE
143 #define __P001  PAGE_READONLY
144 #define __P010  PAGE_COPY
145 #define __P011  PAGE_COPY
146 #define __P100  PAGE_READONLY
147 #define __P101  PAGE_READONLY
148 #define __P110  PAGE_COPY
149 #define __P111  PAGE_COPY
150 
151 #define __S000  PAGE_NONE
152 #define __S001  PAGE_READONLY
153 #define __S010  PAGE_SHARED
154 #define __S011  PAGE_SHARED
155 #define __S100  PAGE_READONLY
156 #define __S101  PAGE_READONLY
157 #define __S110  PAGE_SHARED
158 #define __S111  PAGE_SHARED
159 
160 #define pgprot_noncached pgprot_noncached
161 
162 static inline pgprot_t pgprot_noncached(pgprot_t _prot)
163 {
164         unsigned long prot = pgprot_val(_prot);
165 
166         prot = (prot & ~_CACHE_MASK);
167 
168         return __pgprot(prot);
169 }
170 
171 #define __swp_type(x)           ((x).val & 0x1f)
172 #define __swp_offset(x)         ((x).val >> 11)
173 #define __swp_entry(type, offset) ((swp_entry_t){(type) | ((offset) << 11)})
174 
175 extern unsigned long empty_zero_page;
176 extern unsigned long zero_page_mask;
177 
178 #define ZERO_PAGE(vaddr) \
179         (virt_to_page((void *)(empty_zero_page + \
180          (((unsigned long)(vaddr)) & zero_page_mask))))
181 
182 #define pgtable_cache_init()    do {} while (0)
183 
184 #define arch_enter_lazy_cpu_mode()      do {} while (0)
185 
186 static inline int pte_write(pte_t pte)
187 {
188         return pte_val(pte) & _PAGE_WRITE;
189 }
190 
191 static inline int pte_dirty(pte_t pte)
192 {
193         return pte_val(pte) & _PAGE_MODIFIED;
194 }
195 
196 static inline int pte_young(pte_t pte)
197 {
198         return pte_val(pte) & _PAGE_ACCESSED;
199 }
200 
201 static inline int pte_file(pte_t pte)
202 {
203         return pte_val(pte) & _PAGE_FILE;
204 }
205 
206 #define pte_special(pte)        (0)
207 
208 static inline pte_t pte_wrprotect(pte_t pte)
209 {
210         pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
211         return pte;
212 }
213 
214 static inline pte_t pte_mkclean(pte_t pte)
215 {
216         pte_val(pte) &= ~(_PAGE_MODIFIED|_PAGE_SILENT_WRITE);
217         return pte;
218 }
219 
220 static inline pte_t pte_mkold(pte_t pte)
221 {
222         pte_val(pte) &= ~(_PAGE_ACCESSED|_PAGE_SILENT_READ);
223         return pte;
224 }
225 
226 static inline pte_t pte_mkwrite(pte_t pte)
227 {
228         pte_val(pte) |= _PAGE_WRITE;
229         if (pte_val(pte) & _PAGE_MODIFIED)
230                 pte_val(pte) |= _PAGE_SILENT_WRITE;
231         return pte;
232 }
233 
234 static inline pte_t pte_mkdirty(pte_t pte)
235 {
236         pte_val(pte) |= _PAGE_MODIFIED;
237         if (pte_val(pte) & _PAGE_WRITE)
238                 pte_val(pte) |= _PAGE_SILENT_WRITE;
239         return pte;
240 }
241 
242 static inline pte_t pte_mkyoung(pte_t pte)
243 {
244         pte_val(pte) |= _PAGE_ACCESSED;
245         if (pte_val(pte) & _PAGE_READ)
246                 pte_val(pte) |= _PAGE_SILENT_READ;
247         return pte;
248 }
249 
250 #define set_pmd(pmdptr, pmdval)         \
251          do { *(pmdptr) = (pmdval); } while (0)
252 #define pte_present(pte)        (pte_val(pte) & _PAGE_PRESENT)
253 
254 extern unsigned long pgd_current;
255 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
256 extern void paging_init(void);
257 
258 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
259 {
260         return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
261 }
262 
263 extern void __update_tlb(struct vm_area_struct *vma,
264         unsigned long address,  pte_t pte);
265 extern void __update_cache(struct vm_area_struct *vma,
266         unsigned long address,  pte_t pte);
267 
268 static inline void update_mmu_cache(struct vm_area_struct *vma,
269         unsigned long address, pte_t *ptep)
270 {
271         pte_t pte = *ptep;
272         __update_tlb(vma, address, pte);
273         __update_cache(vma, address, pte);
274 }
275 
276 #ifndef __ASSEMBLY__
277 #include <asm-generic/pgtable.h>
278 
279 void setup_memory(void);
280 #endif /* __ASSEMBLY__ */
281 
282 #endif /* _ASM_SCORE_PGTABLE_H */
283 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp