blob: a1ba761d0573637ffb79ff4f9d6624d644dad9ce [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _CRIS_PGALLOC_H
2#define _CRIS_PGALLOC_H
3
4#include <linux/threads.h>
5#include <linux/mm.h>
6
7#define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, pte)
8#define pmd_populate(mm, pmd, pte) pmd_set(pmd, page_address(pte))
Martin Schwidefsky2f569af2008-02-08 04:22:04 -08009#define pmd_pgtable(pmd) pmd_page(pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11/*
12 * Allocate and free page tables.
13 */
14
Adrian Bunkd9b54442005-11-07 00:58:44 -080015static inline pgd_t *pgd_alloc (struct mm_struct *mm)
Linus Torvalds1da177e2005-04-16 15:20:36 -070016{
17 return (pgd_t *)get_zeroed_page(GFP_KERNEL);
18}
19
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080020static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021{
22 free_page((unsigned long)pgd);
23}
24
Adrian Bunkd9b54442005-11-07 00:58:44 -080025static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070026{
27 pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
28 return pte;
29}
30
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080031static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070032{
33 struct page *pte;
34 pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080035 pgtable_page_ctor(pte);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 return pte;
37}
38
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080039static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040{
41 free_page((unsigned long)pte);
42}
43
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080044static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070045{
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080046 pgtable_page_dtor(pte);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 __free_page(pte);
48}
49
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080050#define __pte_free_tlb(tlb,pte) \
51do { \
52 pgtable_page_dtor(pte); \
53 tlb_remove_page((tlb), pte); \
54} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#define check_pgt_cache() do { } while (0)
57
58#endif