Path: blob/master/arch/unicore32/include/asm/pgalloc.h
10818 views
/*1* linux/arch/unicore32/include/asm/pgalloc.h2*3* Code specific to PKUnity SoC and UniCore ISA4*5* Copyright (C) 2001-2010 GUAN Xue-tao6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License version 2 as9* published by the Free Software Foundation.10*/11#ifndef __UNICORE_PGALLOC_H__12#define __UNICORE_PGALLOC_H__1314#include <asm/pgtable-hwdef.h>15#include <asm/processor.h>16#include <asm/cacheflush.h>17#include <asm/tlbflush.h>1819#define check_pgt_cache() do { } while (0)2021#define _PAGE_USER_TABLE (PMD_TYPE_TABLE | PMD_PRESENT)22#define _PAGE_KERNEL_TABLE (PMD_TYPE_TABLE | PMD_PRESENT)2324extern pgd_t *get_pgd_slow(struct mm_struct *mm);25extern void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd);2627#define pgd_alloc(mm) get_pgd_slow(mm)28#define pgd_free(mm, pgd) free_pgd_slow(mm, pgd)2930#define PGALLOC_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO)3132/*33* Allocate one PTE table.34*/35static inline pte_t *36pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)37{38pte_t *pte;3940pte = (pte_t *)__get_free_page(PGALLOC_GFP);41if (pte)42clean_dcache_area(pte, PTRS_PER_PTE * sizeof(pte_t));4344return pte;45}4647static inline pgtable_t48pte_alloc_one(struct mm_struct *mm, unsigned long addr)49{50struct page *pte;5152pte = alloc_pages(PGALLOC_GFP, 0);53if (pte) {54if (!PageHighMem(pte)) {55void *page = page_address(pte);56clean_dcache_area(page, PTRS_PER_PTE * sizeof(pte_t));57}58pgtable_page_ctor(pte);59}6061return pte;62}6364/*65* Free one PTE table.66*/67static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)68{69if (pte)70free_page((unsigned long)pte);71}7273static inline void pte_free(struct mm_struct *mm, pgtable_t pte)74{75pgtable_page_dtor(pte);76__free_page(pte);77}7879static inline void __pmd_populate(pmd_t *pmdp, unsigned long pmdval)80{81set_pmd(pmdp, __pmd(pmdval));82flush_pmd_entry(pmdp);83}8485/*86* Populate the pmdp entry with a pointer to the pte. This pmd is part87* of the mm address space.88*/89static inline void90pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)91{92unsigned long pte_ptr = (unsigned long)ptep;9394/*95* The pmd must be loaded with the physical96* address of the PTE table97*/98__pmd_populate(pmdp, __pa(pte_ptr) | _PAGE_KERNEL_TABLE);99}100101static inline void102pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)103{104__pmd_populate(pmdp,105page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE);106}107#define pmd_pgtable(pmd) pmd_page(pmd)108109#endif110111112