pgtable-3level.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef __ASM_SH_PGTABLE_3LEVEL_H
  2. #define __ASM_SH_PGTABLE_3LEVEL_H
  3. #include <asm-generic/pgtable-nopud.h>
  4. /*
  5. * Some cores need a 3-level page table layout, for example when using
  6. * 64-bit PTEs and 4K pages.
  7. */
  8. #define PAGETABLE_LEVELS 3
  9. #define PTE_MAGNITUDE 3 /* 64-bit PTEs on SH-X2 TLB */
  10. /* PGD bits */
  11. #define PGDIR_SHIFT 30
  12. #define PTRS_PER_PGD 4
  13. #define USER_PTRS_PER_PGD 2
  14. /* PMD bits */
  15. #define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT - PTE_MAGNITUDE))
  16. #define PMD_SIZE (1UL << PMD_SHIFT)
  17. #define PMD_MASK (~(PMD_SIZE-1))
  18. #define PTRS_PER_PMD ((1 << PGDIR_SHIFT) / PMD_SIZE)
  19. #define pmd_ERROR(e) \
  20. printk("%s:%d: bad pmd %016llx.\n", __FILE__, __LINE__, pmd_val(e))
  21. typedef struct { unsigned long long pmd; } pmd_t;
  22. #define pmd_val(x) ((x).pmd)
  23. #define __pmd(x) ((pmd_t) { (x) } )
  24. static inline unsigned long pud_page_vaddr(pud_t pud)
  25. {
  26. return pud_val(pud);
  27. }
  28. #define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
  29. static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
  30. {
  31. return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
  32. }
  33. #define pud_none(x) (!pud_val(x))
  34. #define pud_present(x) (pud_val(x))
  35. #define pud_clear(xp) do { set_pud(xp, __pud(0)); } while (0)
  36. #define pud_bad(x) (pud_val(x) & ~PAGE_MASK)
  37. /*
  38. * (puds are folded into pgds so this doesn't get actually called,
  39. * but the define is needed for a generic inline function.)
  40. */
  41. #define set_pud(pudptr, pudval) do { *(pudptr) = (pudval); } while(0)
  42. #endif /* __ASM_SH_PGTABLE_3LEVEL_H */