pgtable-ppc64-4k.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _ASM_POWERPC_PGTABLE_PPC64_4K_H
  2. #define _ASM_POWERPC_PGTABLE_PPC64_4K_H
  3. /*
  4. * Entries per page directory level. The PTE level must use a 64b record
  5. * for each page table entry. The PMD and PGD level use a 32b record for
  6. * each entry by assuming that each entry is page aligned.
  7. */
  8. #define PTE_INDEX_SIZE 9
  9. #define PMD_INDEX_SIZE 7
  10. #define PUD_INDEX_SIZE 9
  11. #define PGD_INDEX_SIZE 9
  12. #ifndef __ASSEMBLY__
  13. #define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_INDEX_SIZE)
  14. #define PMD_TABLE_SIZE (sizeof(pmd_t) << PMD_INDEX_SIZE)
  15. #define PUD_TABLE_SIZE (sizeof(pud_t) << PUD_INDEX_SIZE)
  16. #define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE)
  17. #endif /* __ASSEMBLY__ */
  18. #define PTRS_PER_PTE (1 << PTE_INDEX_SIZE)
  19. #define PTRS_PER_PMD (1 << PMD_INDEX_SIZE)
  20. #define PTRS_PER_PUD (1 << PUD_INDEX_SIZE)
  21. #define PTRS_PER_PGD (1 << PGD_INDEX_SIZE)
  22. /* PMD_SHIFT determines what a second-level page table entry can map */
  23. #define PMD_SHIFT (PAGE_SHIFT + PTE_INDEX_SIZE)
  24. #define PMD_SIZE (1UL << PMD_SHIFT)
  25. #define PMD_MASK (~(PMD_SIZE-1))
  26. /* With 4k base page size, hugepage PTEs go at the PMD level */
  27. #define MIN_HUGEPTE_SHIFT PMD_SHIFT
  28. /* PUD_SHIFT determines what a third-level page table entry can map */
  29. #define PUD_SHIFT (PMD_SHIFT + PMD_INDEX_SIZE)
  30. #define PUD_SIZE (1UL << PUD_SHIFT)
  31. #define PUD_MASK (~(PUD_SIZE-1))
  32. /* PGDIR_SHIFT determines what a fourth-level page table entry can map */
  33. #define PGDIR_SHIFT (PUD_SHIFT + PUD_INDEX_SIZE)
  34. #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
  35. #define PGDIR_MASK (~(PGDIR_SIZE-1))
  36. /* Bits to mask out from a PMD to get to the PTE page */
  37. #define PMD_MASKED_BITS 0
  38. /* Bits to mask out from a PUD to get to the PMD page */
  39. #define PUD_MASKED_BITS 0
  40. /* Bits to mask out from a PGD to get to the PUD page */
  41. #define PGD_MASKED_BITS 0
  42. /*
  43. * 4-level page tables related bits
  44. */
  45. #define pgd_none(pgd) (!pgd_val(pgd))
  46. #define pgd_bad(pgd) (pgd_val(pgd) == 0)
  47. #define pgd_present(pgd) (pgd_val(pgd) != 0)
  48. #define pgd_clear(pgdp) (pgd_val(*(pgdp)) = 0)
  49. #define pgd_page_vaddr(pgd) (pgd_val(pgd) & ~PGD_MASKED_BITS)
  50. #ifndef __ASSEMBLY__
  51. static inline pte_t pgd_pte(pgd_t pgd)
  52. {
  53. return __pte(pgd_val(pgd));
  54. }
  55. static inline pgd_t pte_pgd(pte_t pte)
  56. {
  57. return __pgd(pte_val(pte));
  58. }
  59. extern struct page *pgd_page(pgd_t pgd);
  60. #endif /* !__ASSEMBLY__ */
  61. #define pud_offset(pgdp, addr) \
  62. (((pud_t *) pgd_page_vaddr(*(pgdp))) + \
  63. (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)))
  64. #define pud_ERROR(e) \
  65. pr_err("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pud_val(e))
  66. /*
  67. * On all 4K setups, remap_4k_pfn() equates to remap_pfn_range() */
  68. #define remap_4k_pfn(vma, addr, pfn, prot) \
  69. remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, (prot))
  70. #endif /* _ASM_POWERPC_PGTABLE_PPC64_4K_H */