pgalloc.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <asm/processor.h>
  11. #include <linux/threads.h>
  12. #include <linux/slab.h>
  13. #include <linux/mm.h>
  14. #define pmd_populate_kernel(mm, pmd, pte) \
  15. set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
  16. static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  17. struct page *pte)
  18. {
  19. set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte)));
  20. }
  21. /*
  22. * Allocate and free page tables
  23. */
  24. static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm)
  25. {
  26. return kcalloc(USER_PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL);
  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_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
  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_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
  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. #define check_pgt_cache() do { } while(0)
  56. #endif /* __ASM_AVR32_PGALLOC_H */