pgalloc.h 1.7 KB

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