0001
0002 #ifndef _ASM_POWERPC_BOOK3S_32_PGALLOC_H
0003 #define _ASM_POWERPC_BOOK3S_32_PGALLOC_H
0004
0005 #include <linux/threads.h>
0006 #include <linux/slab.h>
0007
0008 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
0009 {
0010 return kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE),
0011 pgtable_gfp_flags(mm, GFP_KERNEL));
0012 }
0013
0014 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
0015 {
0016 kmem_cache_free(PGT_CACHE(PGD_INDEX_SIZE), pgd);
0017 }
0018
0019
0020
0021
0022
0023
0024 #define pmd_free(mm, x) do { } while (0)
0025 #define __pmd_free_tlb(tlb,x,a) do { } while (0)
0026
0027
0028 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp,
0029 pte_t *pte)
0030 {
0031 *pmdp = __pmd(__pa(pte) | _PMD_PRESENT);
0032 }
0033
0034 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,
0035 pgtable_t pte_page)
0036 {
0037 *pmdp = __pmd(__pa(pte_page) | _PMD_PRESENT);
0038 }
0039
0040 static inline void pgtable_free(void *table, unsigned index_size)
0041 {
0042 if (!index_size) {
0043 pte_fragment_free((unsigned long *)table, 0);
0044 } else {
0045 BUG_ON(index_size > MAX_PGTABLE_INDEX_SIZE);
0046 kmem_cache_free(PGT_CACHE(index_size), table);
0047 }
0048 }
0049
0050 #define get_hugepd_cache_index(x) (x)
0051
0052 static inline void pgtable_free_tlb(struct mmu_gather *tlb,
0053 void *table, int shift)
0054 {
0055 unsigned long pgf = (unsigned long)table;
0056 BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
0057 pgf |= shift;
0058 tlb_remove_table(tlb, (void *)pgf);
0059 }
0060
0061 static inline void __tlb_remove_table(void *_table)
0062 {
0063 void *table = (void *)((unsigned long)_table & ~MAX_PGTABLE_INDEX_SIZE);
0064 unsigned shift = (unsigned long)_table & MAX_PGTABLE_INDEX_SIZE;
0065
0066 pgtable_free(table, shift);
0067 }
0068
0069 static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
0070 unsigned long address)
0071 {
0072 pgtable_free_tlb(tlb, table, 0);
0073 }
0074 #endif