1/*
2 *  linux/include/asm-arm/pgalloc.h
3 *
4 *  Copyright (C) 2000-2001 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef _ASMARM_PGALLOC_H
11#define _ASMARM_PGALLOC_H
12
13#include <asm/processor.h>
14#include <asm/cacheflush.h>
15#include <asm/tlbflush.h>
16#include <linux/slab.h>
17
18extern struct kmem_cache *pte_cache;
19
20static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr){
21	return kmem_cache_alloc(pte_cache, GFP_KERNEL);
22}
23
24static inline void pte_free_kernel(pte_t *pte){
25        if (pte)
26                kmem_cache_free(pte_cache, pte);
27}
28
29/*
30 * Populate the pmdp entry with a pointer to the pte.  This pmd is part
31 * of the mm address space.
32 *
33 * If 'mm' is the init tasks mm, then we are doing a vmalloc, and we
34 * need to set stuff up correctly for it.
35 */
36static inline void
37pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
38{
39        set_pmd(pmdp, (unsigned long)ptep | 1);
40}
41
42#define pte_alloc_one(mm,addr)  ((struct page *)pte_alloc_one_kernel(mm,addr))
43#define pte_free(pte)           pte_free_kernel((pte_t *)pte)
44#define pmd_populate(mm,pmdp,ptep) pmd_populate_kernel(mm,pmdp,(pte_t *)ptep)
45
46/*
47 * Since we have only two-level page tables, these are trivial
48 *
49 * trick __pmd_alloc into optimising away. The actual value is irrelevant though as it
50 * is thrown away. It just cant be zero. -IM
51 */
52
53#define pmd_alloc_one(mm,addr)		({ BUG(); ((pmd_t *)2); })
54#define pmd_free(pmd)			do { } while (0)
55#define pgd_populate(mm,pmd,pte)	BUG()
56
57extern pgd_t *get_pgd_slow(struct mm_struct *mm);
58extern void free_pgd_slow(pgd_t *pgd);
59
60#define pgd_alloc(mm)			get_pgd_slow(mm)
61#define pgd_free(pgd)			free_pgd_slow(pgd)
62
63#define check_pgt_cache()		do { } while (0)
64
65#endif
66