blob: 235ece437dddc7196be819a8b7b30dc3f26028a5 [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);
Kirill A. Shutemov26db3902013-11-14 14:31:17 -080035 if (!pte)
36 return NULL;
Kirill A. Shutemov0da53032013-11-14 14:31:29 -080037 if (!pgtable_page_ctor(pte)) {
38 __free_page(pte);
39 return NULL;
40 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 return pte;
42}
43
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080044static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070045{
46 free_page((unsigned long)pte);
47}
48
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080049static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080051 pgtable_page_dtor(pte);
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 __free_page(pte);
53}
54
Benjamin Herrenschmidt9e1b32c2009-07-22 15:44:28 +100055#define __pte_free_tlb(tlb,pte,address) \
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080056do { \
57 pgtable_page_dtor(pte); \
58 tlb_remove_page((tlb), pte); \
59} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#define check_pgt_cache() do { } while (0)
62
63#endif