root/arch/m68k/include/asm/mcf_pgalloc.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. pte_free_kernel
  2. pte_alloc_one_kernel
  3. pmd_alloc_kernel
  4. __pte_free_tlb
  5. pte_alloc_one
  6. pte_free
  7. pgd_free
  8. pgd_alloc

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

/* [<][>][^][v][top][bottom][index][help] */