pgalloc.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _ASM_SCORE_PGALLOC_H
  2. #define _ASM_SCORE_PGALLOC_H
  3. #include <linux/mm.h>
  4. static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
  5. pte_t *pte)
  6. {
  7. set_pmd(pmd, __pmd((unsigned long)pte));
  8. }
  9. static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  10. pgtable_t pte)
  11. {
  12. set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
  13. }
  14. #define pmd_pgtable(pmd) pmd_page(pmd)
  15. static inline pgd_t *pgd_alloc(struct mm_struct *mm)
  16. {
  17. pgd_t *ret, *init;
  18. ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
  19. if (ret) {
  20. init = pgd_offset(&init_mm, 0UL);
  21. pgd_init((unsigned long)ret);
  22. memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
  23. (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
  24. }
  25. return ret;
  26. }
  27. static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
  28. {
  29. free_pages((unsigned long)pgd, PGD_ORDER);
  30. }
  31. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  32. unsigned long address)
  33. {
  34. pte_t *pte;
  35. pte = (pte_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO,
  36. PTE_ORDER);
  37. return pte;
  38. }
  39. static inline struct page *pte_alloc_one(struct mm_struct *mm,
  40. unsigned long address)
  41. {
  42. struct page *pte;
  43. pte = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER);
  44. if (pte) {
  45. clear_highpage(pte);
  46. pgtable_page_ctor(pte);
  47. }
  48. return pte;
  49. }
  50. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  51. {
  52. free_pages((unsigned long)pte, PTE_ORDER);
  53. }
  54. static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
  55. {
  56. pgtable_page_dtor(pte);
  57. __free_pages(pte, PTE_ORDER);
  58. }
  59. #define __pte_free_tlb(tlb, pte, buf) \
  60. do { \
  61. pgtable_page_dtor(pte); \
  62. tlb_remove_page((tlb), pte); \
  63. } while (0)
  64. #define check_pgt_cache() do {} while (0)
  65. #endif /* _ASM_SCORE_PGALLOC_H */