root/arch/unicore32/include/asm/pgalloc.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. pte_alloc_one_kernel
  2. pte_alloc_one
  3. __pmd_populate
  4. pmd_populate_kernel
  5. pmd_populate

   1 /* SPDX-License-Identifier: GPL-2.0-only */
   2 /*
   3  * linux/arch/unicore32/include/asm/pgalloc.h
   4  *
   5  * Code specific to PKUnity SoC and UniCore ISA
   6  *
   7  * Copyright (C) 2001-2010 GUAN Xue-tao
   8  */
   9 #ifndef __UNICORE_PGALLOC_H__
  10 #define __UNICORE_PGALLOC_H__
  11 
  12 #include <asm/pgtable-hwdef.h>
  13 #include <asm/processor.h>
  14 #include <asm/cacheflush.h>
  15 #include <asm/tlbflush.h>
  16 
  17 #define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
  18 #define __HAVE_ARCH_PTE_ALLOC_ONE
  19 #include <asm-generic/pgalloc.h>
  20 
  21 #define _PAGE_USER_TABLE        (PMD_TYPE_TABLE | PMD_PRESENT)
  22 #define _PAGE_KERNEL_TABLE      (PMD_TYPE_TABLE | PMD_PRESENT)
  23 
  24 extern pgd_t *get_pgd_slow(struct mm_struct *mm);
  25 extern void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd);
  26 
  27 #define pgd_alloc(mm)                   get_pgd_slow(mm)
  28 #define pgd_free(mm, pgd)               free_pgd_slow(mm, pgd)
  29 
  30 /*
  31  * Allocate one PTE table.
  32  */
  33 static inline pte_t *
  34 pte_alloc_one_kernel(struct mm_struct *mm)
  35 {
  36         pte_t *pte = __pte_alloc_one_kernel(mm);
  37 
  38         if (pte)
  39                 clean_dcache_area(pte, PTRS_PER_PTE * sizeof(pte_t));
  40 
  41         return pte;
  42 }
  43 
  44 static inline pgtable_t
  45 pte_alloc_one(struct mm_struct *mm)
  46 {
  47         struct page *pte;
  48 
  49         pte = __pte_alloc_one(mm, GFP_PGTABLE_USER);
  50         if (!pte)
  51                 return NULL;
  52         if (!PageHighMem(pte))
  53                 clean_pte_table(page_address(pte));
  54         return pte;
  55 }
  56 
  57 static inline void __pmd_populate(pmd_t *pmdp, unsigned long pmdval)
  58 {
  59         set_pmd(pmdp, __pmd(pmdval));
  60         flush_pmd_entry(pmdp);
  61 }
  62 
  63 /*
  64  * Populate the pmdp entry with a pointer to the pte.  This pmd is part
  65  * of the mm address space.
  66  */
  67 static inline void
  68 pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
  69 {
  70         unsigned long pte_ptr = (unsigned long)ptep;
  71 
  72         /*
  73          * The pmd must be loaded with the physical
  74          * address of the PTE table
  75          */
  76         __pmd_populate(pmdp, __pa(pte_ptr) | _PAGE_KERNEL_TABLE);
  77 }
  78 
  79 static inline void
  80 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
  81 {
  82         __pmd_populate(pmdp,
  83                         page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE);
  84 }
  85 #define pmd_pgtable(pmd) pmd_page(pmd)
  86 
  87 #endif

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