pgalloc_64.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef _X86_64_PGALLOC_H
  2. #define _X86_64_PGALLOC_H
  3. #include <asm/pda.h>
  4. static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
  5. {
  6. set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)));
  7. }
  8. static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
  9. {
  10. set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
  11. }
  12. static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
  13. {
  14. set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
  15. }
  16. #define pmd_pgtable(pmd) pmd_page(pmd)
  17. static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
  18. {
  19. set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
  20. }
  21. static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
  22. {
  23. BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
  24. free_page((unsigned long)pmd);
  25. }
  26. static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
  27. {
  28. return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
  29. }
  30. static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
  31. {
  32. return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
  33. }
  34. static inline void pud_free(struct mm_struct *mm, pud_t *pud)
  35. {
  36. BUG_ON((unsigned long)pud & (PAGE_SIZE-1));
  37. free_page((unsigned long)pud);
  38. }
  39. extern void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd);
  40. extern void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud);
  41. #endif /* _X86_64_PGALLOC_H */