pgalloc.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __ASM_AVR32_PGALLOC_H
  9. #define __ASM_AVR32_PGALLOC_H
  10. #include <linux/mm.h>
  11. static inline void pmd_populate_kernel(struct mm_struct *mm,
  12. pmd_t *pmd, pte_t *pte)
  13. {
  14. set_pmd(pmd, __pmd((unsigned long)pte));
  15. }
  16. static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  17. pgtable_t pte)
  18. {
  19. set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
  20. }
  21. #define pmd_pgtable(pmd) pmd_page(pmd)
  22. /*
  23. * Allocate and free page tables
  24. */
  25. static inline pgd_t *pgd_alloc(struct mm_struct *mm)
  26. {
  27. pgd_t *pgd;
  28. pgd = (pgd_t *)get_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
  29. if (likely(pgd))
  30. memcpy(pgd + USER_PTRS_PER_PGD,
  31. swapper_pg_dir + USER_PTRS_PER_PGD,
  32. (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
  33. return pgd;
  34. }
  35. static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
  36. {
  37. free_page((unsigned long)pgd);
  38. }
  39. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  40. unsigned long address)
  41. {
  42. pte_t *pte;
  43. pte = (pte_t *)get_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
  44. return pte;
  45. }
  46. static inline struct page *pte_alloc_one(struct mm_struct *mm,
  47. unsigned long address)
  48. {
  49. struct page *pte;
  50. pte = alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
  51. if (!pte)
  52. return NULL;
  53. pgtable_page_ctor(pte);
  54. return pte;
  55. }
  56. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  57. {
  58. free_page((unsigned long)pte);
  59. }
  60. static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
  61. {
  62. pgtable_page_dtor(pte);
  63. __free_page(pte);
  64. }
  65. #define __pte_free_tlb(tlb,pte) \
  66. do { \
  67. pgtable_page_dtor(pte); \
  68. tlb_remove_page((tlb), pte); \
  69. } while (0)
  70. #define check_pgt_cache() do { } while(0)
  71. #endif /* __ASM_AVR32_PGALLOC_H */