pgalloc.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __ASM_SH_PGALLOC_H
  2. #define __ASM_SH_PGALLOC_H
  3. static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
  4. pte_t *pte)
  5. {
  6. set_pmd(pmd, __pmd((unsigned long)pte));
  7. }
  8. static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  9. struct page *pte)
  10. {
  11. set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
  12. }
  13. /*
  14. * Allocate and free page tables.
  15. */
  16. static inline pgd_t *pgd_alloc(struct mm_struct *mm)
  17. {
  18. pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT);
  19. if (pgd) {
  20. memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
  21. memcpy(pgd + USER_PTRS_PER_PGD,
  22. swapper_pg_dir + USER_PTRS_PER_PGD,
  23. (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
  24. }
  25. return pgd;
  26. }
  27. static inline void pgd_free(pgd_t *pgd)
  28. {
  29. free_page((unsigned long)pgd);
  30. }
  31. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  32. unsigned long address)
  33. {
  34. return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
  35. }
  36. static inline struct page *pte_alloc_one(struct mm_struct *mm,
  37. unsigned long address)
  38. {
  39. return alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
  40. }
  41. static inline void pte_free_kernel(pte_t *pte)
  42. {
  43. free_page((unsigned long)pte);
  44. }
  45. static inline void pte_free(struct page *pte)
  46. {
  47. __free_page(pte);
  48. }
  49. #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
  50. /*
  51. * allocating and freeing a pmd is trivial: the 1-entry pmd is
  52. * inside the pgd, so has no extra memory associated with it.
  53. */
  54. #define pmd_free(x) do { } while (0)
  55. #define __pmd_free_tlb(tlb,x) do { } while (0)
  56. #define check_pgt_cache() do { } while (0)
  57. #endif /* __ASM_SH_PGALLOC_H */