blob: fdbedacc7375158990236e13b546a7fa1c92a8a6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ALPHA_PGALLOC_H
2#define _ALPHA_PGALLOC_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <linux/mm.h>
5#include <linux/mmzone.h>
6
7/*
8 * Allocate and free page tables. The xxx_kernel() versions are
9 * used to allocate a kernel page table - this turns on ASN bits
10 * if any.
11 */
12
13static inline void
14pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
15{
16 pmd_set(pmd, (pte_t *)(page_to_pa(pte) + PAGE_OFFSET));
17}
18
19static inline void
20pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
21{
22 pmd_set(pmd, pte);
23}
24
25static inline void
26pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
27{
28 pgd_set(pgd, pmd);
29}
30
31extern pgd_t *pgd_alloc(struct mm_struct *mm);
32
33static inline void
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080034pgd_free(struct mm_struct *mm, pgd_t *pgd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035{
36 free_page((unsigned long)pgd);
37}
38
39static inline pmd_t *
40pmd_alloc_one(struct mm_struct *mm, unsigned long address)
41{
42 pmd_t *ret = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
43 return ret;
44}
45
46static inline void
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080047pmd_free(struct mm_struct *mm, pmd_t *pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048{
49 free_page((unsigned long)pmd);
50}
51
52extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr);
53
54static inline void
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080055pte_free_kernel(struct mm_struct *mm, pte_t *pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056{
57 free_page((unsigned long)pte);
58}
59
60static inline struct page *
61pte_alloc_one(struct mm_struct *mm, unsigned long addr)
62{
63 pte_t *pte = pte_alloc_one_kernel(mm, addr);
64 if (pte)
65 return virt_to_page(pte);
66 return NULL;
67}
68
69static inline void
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080070pte_free(struct mm_struct *mm, struct page *page)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
72 __free_page(page);
73}
74
75#define check_pgt_cache() do { } while (0)
76
77#endif /* _ALPHA_PGALLOC_H */