1 /*
2 * linux/include/asm-arm/proc-armv/pgalloc.h
3 *
4 * Copyright (C) 2001 Russell King
5 *
6 * Page table allocation/freeing primitives for 32-bit ARM processors.
7 */
8
9 /* unfortunately, this includes linux/mm.h and the rest of the universe. */
10 #include <linux/slab.h>
11
12 extern kmem_cache_t *pte_cache;
13
14 /*
15 * Allocate one PTE table.
16 *
17 * Note that we keep the processor copy of the PTE entries separate
18 * from the Linux copy. The processor copies are offset by -PTRS_PER_PTE
19 * words from the Linux copy.
20 */
pte_alloc_one(struct mm_struct * mm,unsigned long address)21 static inline pte_t *pte_alloc_one(struct mm_struct *mm, unsigned long address)
22 {
23 pte_t *pte;
24
25 pte = kmem_cache_alloc(pte_cache, GFP_KERNEL);
26 if (pte)
27 pte += PTRS_PER_PTE;
28 return pte;
29 }
30
31 /*
32 * Free one PTE table.
33 */
pte_free_slow(pte_t * pte)34 static inline void pte_free_slow(pte_t *pte)
35 {
36 if (pte) {
37 pte -= PTRS_PER_PTE;
38 kmem_cache_free(pte_cache, pte);
39 }
40 }
41
42 /*
43 * Populate the pmdp entry with a pointer to the pte. This pmd is part
44 * of the mm address space.
45 *
46 * If 'mm' is the init tasks mm, then we are doing a vmalloc, and we
47 * need to set stuff up correctly for it.
48 */
49 #define pmd_populate(mm,pmdp,pte) \
50 do { \
51 unsigned long __prot; \
52 if (mm == &init_mm) \
53 __prot = _PAGE_KERNEL_TABLE; \
54 else \
55 __prot = _PAGE_USER_TABLE; \
56 set_pmd(pmdp, __mk_pmd(pte, __prot)); \
57 } while (0)
58
59