pgalloc.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef _ALPHA_PGALLOC_H
  2. #define _ALPHA_PGALLOC_H
  3. #include <linux/mm.h>
  4. #include <linux/mmzone.h>
  5. /*
  6. * Allocate and free page tables. The xxx_kernel() versions are
  7. * used to allocate a kernel page table - this turns on ASN bits
  8. * if any.
  9. */
  10. static inline void
  11. pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t pte)
  12. {
  13. pmd_set(pmd, (pte_t *)(page_to_pa(pte) + PAGE_OFFSET));
  14. }
  15. #define pmd_pgtable(pmd) pmd_page(pmd)
  16. static inline void
  17. pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
  18. {
  19. pmd_set(pmd, pte);
  20. }
  21. static inline void
  22. pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
  23. {
  24. pgd_set(pgd, pmd);
  25. }
  26. extern pgd_t *pgd_alloc(struct mm_struct *mm);
  27. static inline void
  28. pgd_free(struct mm_struct *mm, pgd_t *pgd)
  29. {
  30. free_page((unsigned long)pgd);
  31. }
  32. static inline pmd_t *
  33. pmd_alloc_one(struct mm_struct *mm, unsigned long address)
  34. {
  35. pmd_t *ret = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
  36. return ret;
  37. }
  38. static inline void
  39. pmd_free(struct mm_struct *mm, pmd_t *pmd)
  40. {
  41. free_page((unsigned long)pmd);
  42. }
  43. static inline pte_t *
  44. pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
  45. {
  46. pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
  47. return pte;
  48. }
  49. static inline void
  50. pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  51. {
  52. free_page((unsigned long)pte);
  53. }
  54. static inline pgtable_t
  55. pte_alloc_one(struct mm_struct *mm, unsigned long address)
  56. {
  57. pte_t *pte = pte_alloc_one_kernel(mm, address);
  58. struct page *page;
  59. if (!pte)
  60. return NULL;
  61. page = virt_to_page(pte);
  62. pgtable_page_ctor(page);
  63. return page;
  64. }
  65. static inline void
  66. pte_free(struct mm_struct *mm, pgtable_t page)
  67. {
  68. pgtable_page_dtor(page);
  69. __free_page(page);
  70. }
  71. #define check_pgt_cache() do { } while (0)
  72. #endif /* _ALPHA_PGALLOC_H */