pgtable-3level.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright 2003 PathScale Inc
  3. * Derived from include/asm-i386/pgtable.h
  4. * Licensed under the GPL
  5. */
  6. #ifndef __UM_PGTABLE_3LEVEL_H
  7. #define __UM_PGTABLE_3LEVEL_H
  8. #include <asm-generic/pgtable-nopud.h>
  9. /* PGDIR_SHIFT determines what a third-level page table entry can map */
  10. #define PGDIR_SHIFT 30
  11. #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
  12. #define PGDIR_MASK (~(PGDIR_SIZE-1))
  13. /* PMD_SHIFT determines the size of the area a second-level page table can
  14. * map
  15. */
  16. #define PMD_SHIFT 21
  17. #define PMD_SIZE (1UL << PMD_SHIFT)
  18. #define PMD_MASK (~(PMD_SIZE-1))
  19. /*
  20. * entries per page directory level
  21. */
  22. #define PTRS_PER_PTE 512
  23. #define PTRS_PER_PMD 512
  24. #define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE)
  25. #define PTRS_PER_PGD 512
  26. #define FIRST_USER_ADDRESS 0
  27. #define pte_ERROR(e) \
  28. printk("%s:%d: bad pte %p(%016lx).\n", __FILE__, __LINE__, &(e), \
  29. pte_val(e))
  30. #define pmd_ERROR(e) \
  31. printk("%s:%d: bad pmd %p(%016lx).\n", __FILE__, __LINE__, &(e), \
  32. pmd_val(e))
  33. #define pgd_ERROR(e) \
  34. printk("%s:%d: bad pgd %p(%016lx).\n", __FILE__, __LINE__, &(e), \
  35. pgd_val(e))
  36. #define pud_none(x) (!(pud_val(x) & ~_PAGE_NEWPAGE))
  37. #define pud_bad(x) ((pud_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
  38. #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
  39. #define pud_populate(mm, pud, pmd) \
  40. set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
  41. #define set_pud(pudptr, pudval) set_64bit((phys_t *) (pudptr), pud_val(pudval))
  42. static inline int pgd_newpage(pgd_t pgd)
  43. {
  44. return(pgd_val(pgd) & _PAGE_NEWPAGE);
  45. }
  46. static inline void pgd_mkuptodate(pgd_t pgd) { pgd_val(pgd) &= ~_PAGE_NEWPAGE; }
  47. #define set_pmd(pmdptr, pmdval) set_64bit((phys_t *) (pmdptr), pmd_val(pmdval))
  48. static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
  49. {
  50. pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL);
  51. if(pmd)
  52. memset(pmd, 0, PAGE_SIZE);
  53. return pmd;
  54. }
  55. extern inline void pud_clear (pud_t *pud)
  56. {
  57. set_pud(pud, __pud(0));
  58. }
  59. #define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK)
  60. #define pud_page_vaddr(pud) \
  61. ((struct page *) __va(pud_val(pud) & PAGE_MASK))
  62. /* Find an entry in the second-level page table.. */
  63. #define pmd_offset(pud, address) ((pmd_t *) pud_page_vaddr(*(pud)) + \
  64. pmd_index(address))
  65. static inline unsigned long pte_pfn(pte_t pte)
  66. {
  67. return phys_to_pfn(pte_val(pte));
  68. }
  69. static inline pte_t pfn_pte(pfn_t page_nr, pgprot_t pgprot)
  70. {
  71. pte_t pte;
  72. phys_t phys = pfn_to_phys(page_nr);
  73. pte_set_val(pte, phys, pgprot);
  74. return pte;
  75. }
  76. static inline pmd_t pfn_pmd(pfn_t page_nr, pgprot_t pgprot)
  77. {
  78. return __pmd((page_nr << PAGE_SHIFT) | pgprot_val(pgprot));
  79. }
  80. /*
  81. * Bits 0 through 3 are taken in the low part of the pte,
  82. * put the 32 bits of offset into the high part.
  83. */
  84. #define PTE_FILE_MAX_BITS 32
  85. #ifdef CONFIG_64BIT
  86. #define pte_to_pgoff(p) ((p).pte >> 32)
  87. #define pgoff_to_pte(off) ((pte_t) { ((off) << 32) | _PAGE_FILE })
  88. #else
  89. #define pte_to_pgoff(pte) ((pte).pte_high)
  90. #define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) })
  91. #endif
  92. #endif
  93. /*
  94. * Overrides for Emacs so that we follow Linus's tabbing style.
  95. * Emacs will notice this stuff at the end of the file and automatically
  96. * adjust the settings for this buffer only. This must remain at the end
  97. * of the file.
  98. * ---------------------------------------------------------------------------
  99. * Local variables:
  100. * c-file-style: "linux"
  101. * End:
  102. */