pgalloc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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(pgd_t * pgd)
  25. {
  26. quicklist_free(0, NULL, pgd);
  27. }
  28. #ifdef CONFIG_PGTABLE_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(pud_t * pud)
  39. {
  40. quicklist_free(0, NULL, pud);
  41. }
  42. #define __pud_free_tlb(tlb, pud) pud_free(pud)
  43. #endif /* CONFIG_PGTABLE_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(pmd_t * pmd)
  54. {
  55. quicklist_free(0, NULL, pmd);
  56. }
  57. #define __pmd_free_tlb(tlb, pmd) pmd_free(pmd)
  58. static inline void
  59. pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, struct page *pte)
  60. {
  61. pmd_val(*pmd_entry) = page_to_phys(pte);
  62. }
  63. static inline void
  64. pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
  65. {
  66. pmd_val(*pmd_entry) = __pa(pte);
  67. }
  68. static inline struct page *pte_alloc_one(struct mm_struct *mm,
  69. unsigned long addr)
  70. {
  71. void *pg = quicklist_alloc(0, GFP_KERNEL, NULL);
  72. return pg ? virt_to_page(pg) : NULL;
  73. }
  74. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  75. unsigned long addr)
  76. {
  77. return quicklist_alloc(0, GFP_KERNEL, NULL);
  78. }
  79. static inline void pte_free(struct page *pte)
  80. {
  81. quicklist_free_page(0, NULL, pte);
  82. }
  83. static inline void pte_free_kernel(pte_t * pte)
  84. {
  85. quicklist_free(0, NULL, pte);
  86. }
  87. static inline void check_pgt_cache(void)
  88. {
  89. quicklist_trim(0, NULL, 25, 16);
  90. }
  91. #define __pte_free_tlb(tlb, pte) pte_free(pte)
  92. #endif /* _ASM_IA64_PGALLOC_H */