pgalloc.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. pgtable_t pte)
  18. {
  19. set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(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. return kcalloc(USER_PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL);
  28. }
  29. static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
  30. {
  31. kfree(pgd);
  32. }
  33. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  34. unsigned long address)
  35. {
  36. pte_t *pte;
  37. pte = (pte_t *)get_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
  38. return pte;
  39. }
  40. static inline struct page *pte_alloc_one(struct mm_struct *mm,
  41. unsigned long address)
  42. {
  43. struct page *pte;
  44. pte = alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
  45. if (!pte)
  46. return NULL;
  47. pgtable_page_ctor(pte);
  48. return pte;
  49. }
  50. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  51. {
  52. free_page((unsigned long)pte);
  53. }
  54. static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
  55. {
  56. pgtable_page_dtor(pte);
  57. __free_page(pte);
  58. }
  59. #define __pte_free_tlb(tlb,pte) \
  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_AVR32_PGALLOC_H */