pgtable-2level.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef _ASM_M32R_PGTABLE_2LEVEL_H
  2. #define _ASM_M32R_PGTABLE_2LEVEL_H
  3. #ifdef __KERNEL__
  4. /*
  5. * traditional M32R two-level paging structure:
  6. */
  7. #define PGDIR_SHIFT 22
  8. #define PTRS_PER_PGD 1024
  9. /*
  10. * the M32R is two-level, so we don't really have any
  11. * PMD directory physically.
  12. */
  13. #define __PAGETABLE_PMD_FOLDED
  14. #define PMD_SHIFT 22
  15. #define PTRS_PER_PMD 1
  16. #define PTRS_PER_PTE 1024
  17. #define pte_ERROR(e) \
  18. printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
  19. #define pmd_ERROR(e) \
  20. printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
  21. #define pgd_ERROR(e) \
  22. printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
  23. /*
  24. * The "pgd_xxx()" functions here are trivial for a folded two-level
  25. * setup: the pgd is never bad, and a pmd always exists (as it's folded
  26. * into the pgd entry)
  27. */
  28. static inline int pgd_none(pgd_t pgd) { return 0; }
  29. static inline int pgd_bad(pgd_t pgd) { return 0; }
  30. static inline int pgd_present(pgd_t pgd) { return 1; }
  31. #define pgd_clear(xp) do { } while (0)
  32. /*
  33. * Certain architectures need to do special things when PTEs
  34. * within a page table are directly modified. Thus, the following
  35. * hook is made available.
  36. */
  37. #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
  38. #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
  39. /*
  40. * (pmds are folded into pgds so this doesn't get actually called,
  41. * but the define is needed for a generic inline function.)
  42. */
  43. #define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
  44. #define set_pgd(pgdptr, pgdval) (*(pgdptr) = pgdval)
  45. #define pgd_page_vaddr(pgd) \
  46. ((unsigned long) __va(pgd_val(pgd) & PAGE_MASK))
  47. #ifndef CONFIG_DISCONTIGMEM
  48. #define pgd_page(pgd) (mem_map + ((pgd_val(pgd) >> PAGE_SHIFT) - PFN_BASE))
  49. #endif /* !CONFIG_DISCONTIGMEM */
  50. static inline pmd_t *pmd_offset(pgd_t * dir, unsigned long address)
  51. {
  52. return (pmd_t *) dir;
  53. }
  54. #define ptep_get_and_clear(mm,addr,xp) __pte(xchg(&(xp)->pte, 0))
  55. #define pte_same(a, b) (pte_val(a) == pte_val(b))
  56. #define pte_page(x) pfn_to_page(pte_pfn(x))
  57. #define pte_none(x) (!pte_val(x))
  58. #define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT)
  59. #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
  60. #define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
  61. #endif /* __KERNEL__ */
  62. #endif /* _ASM_M32R_PGTABLE_2LEVEL_H */