pgtable.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. /* pgtable.h: FR-V page table mangling
  2. *
  3. * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. *
  11. * Derived from:
  12. * include/asm-m68knommu/pgtable.h
  13. * include/asm-i386/pgtable.h
  14. */
  15. #ifndef _ASM_PGTABLE_H
  16. #define _ASM_PGTABLE_H
  17. #include <asm/mem-layout.h>
  18. #include <asm/setup.h>
  19. #include <asm/processor.h>
  20. #ifndef __ASSEMBLY__
  21. #include <linux/threads.h>
  22. #include <linux/slab.h>
  23. #include <linux/list.h>
  24. #include <linux/spinlock.h>
  25. #include <linux/sched.h>
  26. struct vm_area_struct;
  27. #endif
  28. #ifndef __ASSEMBLY__
  29. #if defined(CONFIG_HIGHPTE)
  30. typedef unsigned long pte_addr_t;
  31. #else
  32. typedef pte_t *pte_addr_t;
  33. #endif
  34. #endif
  35. /*****************************************************************************/
  36. /*
  37. * MMU-less operation case first
  38. */
  39. #ifndef CONFIG_MMU
  40. #define pgd_present(pgd) (1) /* pages are always present on NO_MM */
  41. #define pgd_none(pgd) (0)
  42. #define pgd_bad(pgd) (0)
  43. #define pgd_clear(pgdp)
  44. #define kern_addr_valid(addr) (1)
  45. #define pmd_offset(a, b) ((void *) 0)
  46. #define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
  47. #define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
  48. #define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */
  49. #define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */
  50. #define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */
  51. #define __swp_type(x) (0)
  52. #define __swp_offset(x) (0)
  53. #define __swp_entry(typ,off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
  54. #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
  55. #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
  56. #ifndef __ASSEMBLY__
  57. static inline int pte_file(pte_t pte) { return 0; }
  58. #endif
  59. #define ZERO_PAGE(vaddr) ({ BUG(); NULL; })
  60. #define swapper_pg_dir ((pgd_t *) NULL)
  61. #define pgtable_cache_init() do {} while (0)
  62. #define arch_enter_lazy_mmu_mode() do {} while (0)
  63. #define arch_leave_lazy_mmu_mode() do {} while (0)
  64. #define arch_enter_lazy_cpu_mode() do {} while (0)
  65. #define arch_leave_lazy_cpu_mode() do {} while (0)
  66. #else /* !CONFIG_MMU */
  67. /*****************************************************************************/
  68. /*
  69. * then MMU operation
  70. */
  71. /*
  72. * ZERO_PAGE is a global shared page that is always zero: used
  73. * for zero-mapped memory areas etc..
  74. */
  75. #ifndef __ASSEMBLY__
  76. extern unsigned long empty_zero_page;
  77. #define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page)
  78. #endif
  79. /*
  80. * we use 2-level page tables, folding the PMD (mid-level table) into the PGE (top-level entry)
  81. * [see Documentation/frv/mmu-layout.txt]
  82. *
  83. * Page Directory:
  84. * - Size: 16KB
  85. * - 64 PGEs per PGD
  86. * - Each PGE holds 1 PUD and covers 64MB
  87. *
  88. * Page Upper Directory:
  89. * - Size: 256B
  90. * - 1 PUE per PUD
  91. * - Each PUE holds 1 PMD and covers 64MB
  92. *
  93. * Page Mid-Level Directory
  94. * - Size: 256B
  95. * - 1 PME per PMD
  96. * - Each PME holds 64 STEs, all of which point to separate chunks of the same Page Table
  97. * - All STEs are instantiated at the same time
  98. *
  99. * Page Table
  100. * - Size: 16KB
  101. * - 4096 PTEs per PT
  102. * - Each Linux PT is subdivided into 64 FR451 PT's, each of which holds 64 entries
  103. *
  104. * Pages
  105. * - Size: 4KB
  106. *
  107. * total PTEs
  108. * = 1 PML4E * 64 PGEs * 1 PUEs * 1 PMEs * 4096 PTEs
  109. * = 1 PML4E * 64 PGEs * 64 STEs * 64 PTEs/FR451-PT
  110. * = 262144 (or 256 * 1024)
  111. */
  112. #define PGDIR_SHIFT 26
  113. #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
  114. #define PGDIR_MASK (~(PGDIR_SIZE - 1))
  115. #define PTRS_PER_PGD 64
  116. #define PUD_SHIFT 26
  117. #define PTRS_PER_PUD 1
  118. #define PUD_SIZE (1UL << PUD_SHIFT)
  119. #define PUD_MASK (~(PUD_SIZE - 1))
  120. #define PUE_SIZE 256
  121. #define PMD_SHIFT 26
  122. #define PMD_SIZE (1UL << PMD_SHIFT)
  123. #define PMD_MASK (~(PMD_SIZE - 1))
  124. #define PTRS_PER_PMD 1
  125. #define PME_SIZE 256
  126. #define __frv_PT_SIZE 256
  127. #define PTRS_PER_PTE 4096
  128. #define USER_PGDS_IN_LAST_PML4 (TASK_SIZE / PGDIR_SIZE)
  129. #define FIRST_USER_ADDRESS 0
  130. #define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
  131. #define KERNEL_PGD_PTRS (PTRS_PER_PGD - USER_PGD_PTRS)
  132. #define TWOLEVEL_PGDIR_SHIFT 26
  133. #define BOOT_USER_PGD_PTRS (__PAGE_OFFSET >> TWOLEVEL_PGDIR_SHIFT)
  134. #define BOOT_KERNEL_PGD_PTRS (PTRS_PER_PGD - BOOT_USER_PGD_PTRS)
  135. #ifndef __ASSEMBLY__
  136. extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
  137. #define pte_ERROR(e) \
  138. printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte)
  139. #define pmd_ERROR(e) \
  140. printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
  141. #define pud_ERROR(e) \
  142. printk("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pmd_val(pud_val(e)))
  143. #define pgd_ERROR(e) \
  144. printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pmd_val(pud_val(pgd_val(e))))
  145. /*
  146. * Certain architectures need to do special things when PTEs
  147. * within a page table are directly modified. Thus, the following
  148. * hook is made available.
  149. */
  150. #define set_pte(pteptr, pteval) \
  151. do { \
  152. *(pteptr) = (pteval); \
  153. asm volatile("dcf %M0" :: "U"(*pteptr)); \
  154. } while(0)
  155. #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
  156. /*
  157. * pgd_offset() returns a (pgd_t *)
  158. * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
  159. */
  160. #define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
  161. /*
  162. * a shortcut which implies the use of the kernel's pgd, instead
  163. * of a process's
  164. */
  165. #define pgd_offset_k(address) pgd_offset(&init_mm, address)
  166. /*
  167. * The "pgd_xxx()" functions here are trivial for a folded two-level
  168. * setup: the pud is never bad, and a pud always exists (as it's folded
  169. * into the pgd entry)
  170. */
  171. static inline int pgd_none(pgd_t pgd) { return 0; }
  172. static inline int pgd_bad(pgd_t pgd) { return 0; }
  173. static inline int pgd_present(pgd_t pgd) { return 1; }
  174. static inline void pgd_clear(pgd_t *pgd) { }
  175. #define pgd_populate(mm, pgd, pud) do { } while (0)
  176. /*
  177. * (puds are folded into pgds so this doesn't get actually called,
  178. * but the define is needed for a generic inline function.)
  179. */
  180. #define set_pgd(pgdptr, pgdval) \
  181. do { \
  182. memcpy((pgdptr), &(pgdval), sizeof(pgd_t)); \
  183. asm volatile("dcf %M0" :: "U"(*(pgdptr))); \
  184. } while(0)
  185. static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
  186. {
  187. return (pud_t *) pgd;
  188. }
  189. #define pgd_page(pgd) (pud_page((pud_t){ pgd }))
  190. #define pgd_page_vaddr(pgd) (pud_page_vaddr((pud_t){ pgd }))
  191. /*
  192. * allocating and freeing a pud is trivial: the 1-entry pud is
  193. * inside the pgd, so has no extra memory associated with it.
  194. */
  195. #define pud_alloc_one(mm, address) NULL
  196. #define pud_free(mm, x) do { } while (0)
  197. #define __pud_free_tlb(tlb, x) do { } while (0)
  198. /*
  199. * The "pud_xxx()" functions here are trivial for a folded two-level
  200. * setup: the pmd is never bad, and a pmd always exists (as it's folded
  201. * into the pud entry)
  202. */
  203. static inline int pud_none(pud_t pud) { return 0; }
  204. static inline int pud_bad(pud_t pud) { return 0; }
  205. static inline int pud_present(pud_t pud) { return 1; }
  206. static inline void pud_clear(pud_t *pud) { }
  207. #define pud_populate(mm, pmd, pte) do { } while (0)
  208. /*
  209. * (pmds are folded into puds so this doesn't get actually called,
  210. * but the define is needed for a generic inline function.)
  211. */
  212. #define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })
  213. #define pud_page(pud) (pmd_page((pmd_t){ pud }))
  214. #define pud_page_vaddr(pud) (pmd_page_vaddr((pmd_t){ pud }))
  215. /*
  216. * (pmds are folded into pgds so this doesn't get actually called,
  217. * but the define is needed for a generic inline function.)
  218. */
  219. extern void __set_pmd(pmd_t *pmdptr, unsigned long __pmd);
  220. #define set_pmd(pmdptr, pmdval) \
  221. do { \
  222. __set_pmd((pmdptr), (pmdval).ste[0]); \
  223. } while(0)
  224. #define __pmd_index(address) 0
  225. static inline pmd_t *pmd_offset(pud_t *dir, unsigned long address)
  226. {
  227. return (pmd_t *) dir + __pmd_index(address);
  228. }
  229. #define pte_same(a, b) ((a).pte == (b).pte)
  230. #define pte_page(x) (mem_map + ((unsigned long)(((x).pte >> PAGE_SHIFT))))
  231. #define pte_none(x) (!(x).pte)
  232. #define pte_pfn(x) ((unsigned long)(((x).pte >> PAGE_SHIFT)))
  233. #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
  234. #define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
  235. #define VMALLOC_VMADDR(x) ((unsigned long) (x))
  236. #endif /* !__ASSEMBLY__ */
  237. /*
  238. * control flags in AMPR registers and TLB entries
  239. */
  240. #define _PAGE_BIT_PRESENT xAMPRx_V_BIT
  241. #define _PAGE_BIT_WP DAMPRx_WP_BIT
  242. #define _PAGE_BIT_NOCACHE xAMPRx_C_BIT
  243. #define _PAGE_BIT_SUPER xAMPRx_S_BIT
  244. #define _PAGE_BIT_ACCESSED xAMPRx_RESERVED8_BIT
  245. #define _PAGE_BIT_DIRTY xAMPRx_M_BIT
  246. #define _PAGE_BIT_NOTGLOBAL xAMPRx_NG_BIT
  247. #define _PAGE_PRESENT xAMPRx_V
  248. #define _PAGE_WP DAMPRx_WP
  249. #define _PAGE_NOCACHE xAMPRx_C
  250. #define _PAGE_SUPER xAMPRx_S
  251. #define _PAGE_ACCESSED xAMPRx_RESERVED8 /* accessed if set */
  252. #define _PAGE_DIRTY xAMPRx_M
  253. #define _PAGE_NOTGLOBAL xAMPRx_NG
  254. #define _PAGE_RESERVED_MASK (xAMPRx_RESERVED8 | xAMPRx_RESERVED13)
  255. #define _PAGE_FILE 0x002 /* set:pagecache unset:swap */
  256. #define _PAGE_PROTNONE 0x000 /* If not present */
  257. #define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
  258. #define __PGPROT_BASE \
  259. (_PAGE_PRESENT | xAMPRx_SS_16Kb | xAMPRx_D | _PAGE_NOTGLOBAL | _PAGE_ACCESSED)
  260. #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
  261. #define PAGE_SHARED __pgprot(__PGPROT_BASE)
  262. #define PAGE_COPY __pgprot(__PGPROT_BASE | _PAGE_WP)
  263. #define PAGE_READONLY __pgprot(__PGPROT_BASE | _PAGE_WP)
  264. #define __PAGE_KERNEL (__PGPROT_BASE | _PAGE_SUPER | _PAGE_DIRTY)
  265. #define __PAGE_KERNEL_NOCACHE (__PGPROT_BASE | _PAGE_SUPER | _PAGE_DIRTY | _PAGE_NOCACHE)
  266. #define __PAGE_KERNEL_RO (__PGPROT_BASE | _PAGE_SUPER | _PAGE_DIRTY | _PAGE_WP)
  267. #define MAKE_GLOBAL(x) __pgprot((x) & ~_PAGE_NOTGLOBAL)
  268. #define PAGE_KERNEL MAKE_GLOBAL(__PAGE_KERNEL)
  269. #define PAGE_KERNEL_RO MAKE_GLOBAL(__PAGE_KERNEL_RO)
  270. #define PAGE_KERNEL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_NOCACHE)
  271. #define _PAGE_TABLE (_PAGE_PRESENT | xAMPRx_SS_16Kb)
  272. #ifndef __ASSEMBLY__
  273. /*
  274. * The FR451 can do execute protection by virtue of having separate TLB miss handlers for
  275. * instruction access and for data access. However, we don't have enough reserved bits to say
  276. * "execute only", so we don't bother. If you can read it, you can execute it and vice versa.
  277. */
  278. #define __P000 PAGE_NONE
  279. #define __P001 PAGE_READONLY
  280. #define __P010 PAGE_COPY
  281. #define __P011 PAGE_COPY
  282. #define __P100 PAGE_READONLY
  283. #define __P101 PAGE_READONLY
  284. #define __P110 PAGE_COPY
  285. #define __P111 PAGE_COPY
  286. #define __S000 PAGE_NONE
  287. #define __S001 PAGE_READONLY
  288. #define __S010 PAGE_SHARED
  289. #define __S011 PAGE_SHARED
  290. #define __S100 PAGE_READONLY
  291. #define __S101 PAGE_READONLY
  292. #define __S110 PAGE_SHARED
  293. #define __S111 PAGE_SHARED
  294. /*
  295. * Define this to warn about kernel memory accesses that are
  296. * done without a 'access_ok(VERIFY_WRITE,..)'
  297. */
  298. #undef TEST_ACCESS_OK
  299. #define pte_present(x) (pte_val(x) & _PAGE_PRESENT)
  300. #define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
  301. #define pmd_none(x) (!pmd_val(x))
  302. #define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
  303. #define pmd_bad(x) (pmd_val(x) & xAMPRx_SS)
  304. #define pmd_clear(xp) do { __set_pmd(xp, 0); } while(0)
  305. #define pmd_page_vaddr(pmd) \
  306. ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
  307. #ifndef CONFIG_DISCONTIGMEM
  308. #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
  309. #endif
  310. #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
  311. /*
  312. * The following only work if pte_present() is true.
  313. * Undefined behaviour if not..
  314. */
  315. static inline int pte_dirty(pte_t pte) { return (pte).pte & _PAGE_DIRTY; }
  316. static inline int pte_young(pte_t pte) { return (pte).pte & _PAGE_ACCESSED; }
  317. static inline int pte_write(pte_t pte) { return !((pte).pte & _PAGE_WP); }
  318. static inline int pte_special(pte_t pte) { return 0; }
  319. static inline pte_t pte_mkclean(pte_t pte) { (pte).pte &= ~_PAGE_DIRTY; return pte; }
  320. static inline pte_t pte_mkold(pte_t pte) { (pte).pte &= ~_PAGE_ACCESSED; return pte; }
  321. static inline pte_t pte_wrprotect(pte_t pte) { (pte).pte |= _PAGE_WP; return pte; }
  322. static inline pte_t pte_mkdirty(pte_t pte) { (pte).pte |= _PAGE_DIRTY; return pte; }
  323. static inline pte_t pte_mkyoung(pte_t pte) { (pte).pte |= _PAGE_ACCESSED; return pte; }
  324. static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte &= ~_PAGE_WP; return pte; }
  325. static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
  326. static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
  327. {
  328. int i = test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep);
  329. asm volatile("dcf %M0" :: "U"(*ptep));
  330. return i;
  331. }
  332. static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
  333. {
  334. unsigned long x = xchg(&ptep->pte, 0);
  335. asm volatile("dcf %M0" :: "U"(*ptep));
  336. return __pte(x);
  337. }
  338. static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
  339. {
  340. set_bit(_PAGE_BIT_WP, ptep);
  341. asm volatile("dcf %M0" :: "U"(*ptep));
  342. }
  343. /*
  344. * Macro to mark a page protection value as "uncacheable"
  345. */
  346. #define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | _PAGE_NOCACHE))
  347. /*
  348. * Conversion functions: convert a page and protection to a page entry,
  349. * and a page entry and page directory to the page they refer to.
  350. */
  351. #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
  352. #define mk_pte_huge(entry) ((entry).pte_low |= _PAGE_PRESENT | _PAGE_PSE)
  353. /* This takes a physical page address that is used by the remapping functions */
  354. #define mk_pte_phys(physpage, pgprot) pfn_pte((physpage) >> PAGE_SHIFT, pgprot)
  355. static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
  356. {
  357. pte.pte &= _PAGE_CHG_MASK;
  358. pte.pte |= pgprot_val(newprot);
  359. return pte;
  360. }
  361. /* to find an entry in a page-table-directory. */
  362. #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
  363. #define pgd_index_k(addr) pgd_index(addr)
  364. /* Find an entry in the bottom-level page table.. */
  365. #define __pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
  366. /*
  367. * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
  368. *
  369. * this macro returns the index of the entry in the pte page which would
  370. * control the given virtual address
  371. */
  372. #define pte_index(address) \
  373. (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
  374. #define pte_offset_kernel(dir, address) \
  375. ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))
  376. #if defined(CONFIG_HIGHPTE)
  377. #define pte_offset_map(dir, address) \
  378. ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
  379. #define pte_offset_map_nested(dir, address) \
  380. ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + pte_index(address))
  381. #define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
  382. #define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
  383. #else
  384. #define pte_offset_map(dir, address) \
  385. ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
  386. #define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
  387. #define pte_unmap(pte) do { } while (0)
  388. #define pte_unmap_nested(pte) do { } while (0)
  389. #endif
  390. /*
  391. * Handle swap and file entries
  392. * - the PTE is encoded in the following format:
  393. * bit 0: Must be 0 (!_PAGE_PRESENT)
  394. * bit 1: Type: 0 for swap, 1 for file (_PAGE_FILE)
  395. * bits 2-7: Swap type
  396. * bits 8-31: Swap offset
  397. * bits 2-31: File pgoff
  398. */
  399. #define __swp_type(x) (((x).val >> 2) & 0x1f)
  400. #define __swp_offset(x) ((x).val >> 8)
  401. #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 2) | ((offset) << 8) })
  402. #define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte })
  403. #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
  404. static inline int pte_file(pte_t pte)
  405. {
  406. return pte.pte & _PAGE_FILE;
  407. }
  408. #define PTE_FILE_MAX_BITS 29
  409. #define pte_to_pgoff(PTE) ((PTE).pte >> 2)
  410. #define pgoff_to_pte(off) __pte((off) << 2 | _PAGE_FILE)
  411. /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
  412. #define PageSkip(page) (0)
  413. #define kern_addr_valid(addr) (1)
  414. #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
  415. remap_pfn_range(vma, vaddr, pfn, size, prot)
  416. #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
  417. #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
  418. #define __HAVE_ARCH_PTEP_SET_WRPROTECT
  419. #define __HAVE_ARCH_PTE_SAME
  420. #include <asm-generic/pgtable.h>
  421. /*
  422. * preload information about a newly instantiated PTE into the SCR0/SCR1 PGE cache
  423. */
  424. static inline void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte)
  425. {
  426. struct mm_struct *mm;
  427. unsigned long ampr;
  428. mm = current->mm;
  429. if (mm) {
  430. pgd_t *pge = pgd_offset(mm, address);
  431. pud_t *pue = pud_offset(pge, address);
  432. pmd_t *pme = pmd_offset(pue, address);
  433. ampr = pme->ste[0] & 0xffffff00;
  434. ampr |= xAMPRx_L | xAMPRx_SS_16Kb | xAMPRx_S | xAMPRx_C |
  435. xAMPRx_V;
  436. } else {
  437. address = ULONG_MAX;
  438. ampr = 0;
  439. }
  440. asm volatile("movgs %0,scr0\n"
  441. "movgs %0,scr1\n"
  442. "movgs %1,dampr4\n"
  443. "movgs %1,dampr5\n"
  444. :
  445. : "r"(address), "r"(ampr)
  446. );
  447. }
  448. #ifdef CONFIG_PROC_FS
  449. extern char *proc_pid_status_frv_cxnr(struct mm_struct *mm, char *buffer);
  450. #endif
  451. extern void __init pgtable_cache_init(void);
  452. #endif /* !__ASSEMBLY__ */
  453. #endif /* !CONFIG_MMU */
  454. #ifndef __ASSEMBLY__
  455. extern void __init paging_init(void);
  456. #endif /* !__ASSEMBLY__ */
  457. #endif /* _ASM_PGTABLE_H */