mcf_pgalloc.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef M68K_MCF_PGALLOC_H
  2. #define M68K_MCF_PGALLOC_H
  3. #include <asm/tlb.h>
  4. #include <asm/tlbflush.h>
  5. extern inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  6. {
  7. free_page((unsigned long) pte);
  8. }
  9. extern const char bad_pmd_string[];
  10. extern inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  11. unsigned long address)
  12. {
  13. unsigned long page = __get_free_page(GFP_DMA|__GFP_REPEAT);
  14. if (!page)
  15. return NULL;
  16. memset((void *)page, 0, PAGE_SIZE);
  17. return (pte_t *) (page);
  18. }
  19. extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
  20. {
  21. return (pmd_t *) pgd;
  22. }
  23. #define pmd_alloc_one_fast(mm, address) ({ BUG(); ((pmd_t *)1); })
  24. #define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); })
  25. #define pte_alloc_one_fast(mm, addr) pte_alloc_one(mm, addr)
  26. #define pmd_populate(mm, pmd, page) (pmd_val(*pmd) = \
  27. (unsigned long)(page_address(page)))
  28. #define pmd_populate_kernel(mm, pmd, pte) (pmd_val(*pmd) = (unsigned long)(pte))
  29. #define pmd_pgtable(pmd) pmd_page(pmd)
  30. static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page,
  31. unsigned long address)
  32. {
  33. __free_page(page);
  34. }
  35. #define __pmd_free_tlb(tlb, pmd, address) do { } while (0)
  36. static inline struct page *pte_alloc_one(struct mm_struct *mm,
  37. unsigned long address)
  38. {
  39. struct page *page = alloc_pages(GFP_DMA|__GFP_REPEAT, 0);
  40. pte_t *pte;
  41. if (!page)
  42. return NULL;
  43. if (!pgtable_page_ctor(page)) {
  44. __free_page(page);
  45. return NULL;
  46. }
  47. pte = kmap(page);
  48. if (pte) {
  49. clear_page(pte);
  50. __flush_page_to_ram(pte);
  51. flush_tlb_kernel_page(pte);
  52. nocache_page(pte);
  53. }
  54. kunmap(page);
  55. return page;
  56. }
  57. extern inline void pte_free(struct mm_struct *mm, struct page *page)
  58. {
  59. __free_page(page);
  60. }
  61. /*
  62. * In our implementation, each pgd entry contains 1 pmd that is never allocated
  63. * or freed. pgd_present is always 1, so this should never be called. -NL
  64. */
  65. #define pmd_free(mm, pmd) BUG()
  66. static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
  67. {
  68. free_page((unsigned long) pgd);
  69. }
  70. static inline pgd_t *pgd_alloc(struct mm_struct *mm)
  71. {
  72. pgd_t *new_pgd;
  73. new_pgd = (pgd_t *)__get_free_page(GFP_DMA | __GFP_NOWARN);
  74. if (!new_pgd)
  75. return NULL;
  76. memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE);
  77. memset(new_pgd, 0, PAGE_OFFSET >> PGDIR_SHIFT);
  78. return new_pgd;
  79. }
  80. #define pgd_populate(mm, pmd, pte) BUG()
  81. #endif /* M68K_MCF_PGALLOC_H */