pgalloc.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef __ASM_SH_PGALLOC_H
  2. #define __ASM_SH_PGALLOC_H
  3. #include <linux/threads.h>
  4. #include <linux/slab.h>
  5. #include <linux/mm.h>
  6. #define pgd_quicklist ((unsigned long *)0)
  7. #define pmd_quicklist ((unsigned long *)0)
  8. #define pte_quicklist ((unsigned long *)0)
  9. #define pgtable_cache_size 0L
  10. #define pmd_populate_kernel(mm, pmd, pte) \
  11. set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
  12. static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  13. struct page *pte)
  14. {
  15. set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte)));
  16. }
  17. /*
  18. * Allocate and free page tables.
  19. */
  20. static inline pgd_t *pgd_alloc(struct mm_struct *mm)
  21. {
  22. unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t));
  23. pgd_t *pgd = (pgd_t *)kmalloc(pgd_size, GFP_KERNEL);
  24. if (pgd)
  25. memset(pgd, 0, pgd_size);
  26. return pgd;
  27. }
  28. static inline void pgd_free(pgd_t *pgd)
  29. {
  30. kfree(pgd);
  31. }
  32. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  33. unsigned long address)
  34. {
  35. pte_t *pte;
  36. pte = (pte_t *) __get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
  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|__GFP_ZERO, 0);
  44. return pte;
  45. }
  46. static inline void pte_free_kernel(pte_t *pte)
  47. {
  48. free_page((unsigned long)pte);
  49. }
  50. static inline void pte_free(struct page *pte)
  51. {
  52. __free_page(pte);
  53. }
  54. #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
  55. /*
  56. * allocating and freeing a pmd is trivial: the 1-entry pmd is
  57. * inside the pgd, so has no extra memory associated with it.
  58. */
  59. #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
  60. #define pmd_free(x) do { } while (0)
  61. #define __pmd_free_tlb(tlb,x) do { } while (0)
  62. #define pgd_populate(mm, pmd, pte) BUG()
  63. #define check_pgt_cache() do { } while (0)
  64. #ifdef CONFIG_CPU_SH4
  65. #define PG_mapped PG_arch_1
  66. #endif
  67. #endif /* __ASM_SH_PGALLOC_H */