pgalloc.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef _CRIS_PGALLOC_H
  2. #define _CRIS_PGALLOC_H
  3. #include <linux/threads.h>
  4. #include <linux/mm.h>
  5. #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, pte)
  6. #define pmd_populate(mm, pmd, pte) pmd_set(pmd, page_address(pte))
  7. #define pmd_pgtable(pmd) pmd_page(pmd)
  8. /*
  9. * Allocate and free page tables.
  10. */
  11. static inline pgd_t *pgd_alloc (struct mm_struct *mm)
  12. {
  13. return (pgd_t *)get_zeroed_page(GFP_KERNEL);
  14. }
  15. static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
  16. {
  17. free_page((unsigned long)pgd);
  18. }
  19. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
  20. {
  21. pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
  22. return pte;
  23. }
  24. static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
  25. {
  26. struct page *pte;
  27. pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
  28. pgtable_page_ctor(pte);
  29. return pte;
  30. }
  31. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  32. {
  33. free_page((unsigned long)pte);
  34. }
  35. static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
  36. {
  37. pgtable_page_dtor(pte);
  38. __free_page(pte);
  39. }
  40. #define __pte_free_tlb(tlb,pte,address) \
  41. do { \
  42. pgtable_page_dtor(pte); \
  43. tlb_remove_page((tlb), pte); \
  44. } while (0)
  45. #define check_pgt_cache() do { } while (0)
  46. #endif