pgalloc.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. pgtable_page_ctor(pte);
  38. return pte;
  39. }
  40. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  41. {
  42. free_page((unsigned long)pte);
  43. }
  44. static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
  45. {
  46. pgtable_page_dtor(pte);
  47. __free_page(pte);
  48. }
  49. #define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, (pte))
  50. /*
  51. * allocating and freeing a pmd is trivial: the 1-entry pmd is
  52. * inside the pgd, so has no extra memory associated with it.
  53. * (In the PAE case we free the pmds as part of the pgd.)
  54. */
  55. #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
  56. #define pmd_free(mm, x) do { } while (0)
  57. #define __pmd_free_tlb(tlb, x, addr) do { } while (0)
  58. #define pgd_populate(mm, pmd, pte) BUG()
  59. #define check_pgt_cache() do { } while (0)
  60. #endif /* _ASM_M32R_PGALLOC_H */