pgalloc.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #ifndef _ASM_IA64_PGALLOC_H
  2. #define _ASM_IA64_PGALLOC_H
  3. /*
  4. * This file contains the functions and defines necessary to allocate
  5. * page tables.
  6. *
  7. * This hopefully works with any (fixed) ia-64 page-size, as defined
  8. * in <asm/page.h> (currently 8192).
  9. *
  10. * Copyright (C) 1998-2001 Hewlett-Packard Co
  11. * David Mosberger-Tang <davidm@hpl.hp.com>
  12. * Copyright (C) 2000, Goutham Rao <goutham.rao@intel.com>
  13. */
  14. #include <linux/compiler.h>
  15. #include <linux/mm.h>
  16. #include <linux/page-flags.h>
  17. #include <linux/threads.h>
  18. #include <linux/quicklist.h>
  19. #include <asm/mmu_context.h>
  20. static inline pgd_t *pgd_alloc(struct mm_struct *mm)
  21. {
  22. return quicklist_alloc(0, GFP_KERNEL, NULL);
  23. }
  24. static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
  25. {
  26. quicklist_free(0, NULL, pgd);
  27. }
  28. #if CONFIG_PGTABLE_LEVELS == 4
  29. static inline void
  30. pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
  31. {
  32. pgd_val(*pgd_entry) = __pa(pud);
  33. }
  34. static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
  35. {
  36. return quicklist_alloc(0, GFP_KERNEL, NULL);
  37. }
  38. static inline void pud_free(struct mm_struct *mm, pud_t *pud)
  39. {
  40. quicklist_free(0, NULL, pud);
  41. }
  42. #define __pud_free_tlb(tlb, pud, address) pud_free((tlb)->mm, pud)
  43. #endif /* CONFIG_PGTABLE_LEVELS == 4 */
  44. static inline void
  45. pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
  46. {
  47. pud_val(*pud_entry) = __pa(pmd);
  48. }
  49. static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
  50. {
  51. return quicklist_alloc(0, GFP_KERNEL, NULL);
  52. }
  53. static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
  54. {
  55. quicklist_free(0, NULL, pmd);
  56. }
  57. #define __pmd_free_tlb(tlb, pmd, address) pmd_free((tlb)->mm, pmd)
  58. static inline void
  59. pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, pgtable_t pte)
  60. {
  61. pmd_val(*pmd_entry) = page_to_phys(pte);
  62. }
  63. #define pmd_pgtable(pmd) pmd_page(pmd)
  64. static inline void
  65. pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
  66. {
  67. pmd_val(*pmd_entry) = __pa(pte);
  68. }
  69. static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr)
  70. {
  71. struct page *page;
  72. void *pg;
  73. pg = quicklist_alloc(0, GFP_KERNEL, NULL);
  74. if (!pg)
  75. return NULL;
  76. page = virt_to_page(pg);
  77. if (!pgtable_page_ctor(page)) {
  78. quicklist_free(0, NULL, pg);
  79. return NULL;
  80. }
  81. return page;
  82. }
  83. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  84. unsigned long addr)
  85. {
  86. return quicklist_alloc(0, GFP_KERNEL, NULL);
  87. }
  88. static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
  89. {
  90. pgtable_page_dtor(pte);
  91. quicklist_free_page(0, NULL, pte);
  92. }
  93. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  94. {
  95. quicklist_free(0, NULL, pte);
  96. }
  97. static inline void check_pgt_cache(void)
  98. {
  99. quicklist_trim(0, NULL, 25, 16);
  100. }
  101. #define __pte_free_tlb(tlb, pte, address) pte_free((tlb)->mm, pte)
  102. #endif /* _ASM_IA64_PGALLOC_H */