pgalloc.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef _ASM_M32R_PGALLOC_H
  2. #define _ASM_M32R_PGALLOC_H
  3. #include <linux/mm.h>
  4. #include <asm/io.h>
  5. #define pmd_populate_kernel(mm, pmd, pte) \
  6. set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
  7. static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  8. pgtable_t pte)
  9. {
  10. set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte)));
  11. }
  12. #define pmd_pgtable(pmd) pmd_page(pmd)
  13. /*
  14. * Allocate and free page tables.
  15. */
  16. static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm)
  17. {
  18. pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
  19. return pgd;
  20. }
  21. static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
  22. {
  23. free_page((unsigned long)pgd);
  24. }
  25. static __inline__ pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  26. unsigned long address)
  27. {
  28. pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
  29. return pte;
  30. }
  31. static __inline__ pgtable_t pte_alloc_one(struct mm_struct *mm,
  32. unsigned long address)
  33. {
  34. struct page *pte = alloc_page(GFP_KERNEL|__GFP_ZERO);
  35. if (!pte)
  36. return NULL;
  37. if (!pgtable_page_ctor(pte)) {
  38. __free_page(pte);
  39. return NULL;
  40. }
  41. return pte;
  42. }
  43. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  44. {
  45. free_page((unsigned long)pte);
  46. }
  47. static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
  48. {
  49. pgtable_page_dtor(pte);
  50. __free_page(pte);
  51. }
  52. #define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, (pte))
  53. /*
  54. * allocating and freeing a pmd is trivial: the 1-entry pmd is
  55. * inside the pgd, so has no extra memory associated with it.
  56. * (In the PAE case we free the pmds as part of the pgd.)
  57. */
  58. #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
  59. #define pmd_free(mm, x) do { } while (0)
  60. #define __pmd_free_tlb(tlb, x, addr) do { } while (0)
  61. #define pgd_populate(mm, pmd, pte) BUG()
  62. #define check_pgt_cache() do { } while (0)
  63. #endif /* _ASM_M32R_PGALLOC_H */