1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2005-2017 Andes Technology Corporation
4 #ifndef _ASMNDS32_PGALLOC_H
5 #define _ASMNDS32_PGALLOC_H
7 #include <asm/processor.h>
8 #include <asm/cacheflush.h>
9 #include <asm/tlbflush.h>
10 #include <asm/proc-fns.h>
12 #define __HAVE_ARCH_PTE_ALLOC_ONE
13 #include <asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */
15 extern pgd_t *pgd_alloc(struct mm_struct *mm);
16 extern void pgd_free(struct mm_struct *mm, pgd_t * pgd);
18 static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
22 pte = __pte_alloc_one(mm, GFP_PGTABLE_USER);
24 cpu_dcache_wb_page((unsigned long)page_address(pte));
30 * Populate the pmdp entry with a pointer to the pte. This pmd is part
31 * of the mm address space.
33 * Ensure that we always set both PMD entries.
36 pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmdp, pte_t * ptep)
38 unsigned long pte_ptr = (unsigned long)ptep;
41 BUG_ON(mm != &init_mm);
44 * The pmd must be loaded with the physical
45 * address of the PTE table
47 pmdval = __pa(pte_ptr) | _PAGE_KERNEL_TABLE;
48 set_pmd(pmdp, __pmd(pmdval));
52 pmd_populate(struct mm_struct *mm, pmd_t * pmdp, pgtable_t ptep)
56 BUG_ON(mm == &init_mm);
58 pmdval = page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE;
59 set_pmd(pmdp, __pmd(pmdval));