MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / asm-x86_64 / pgalloc.h
blobbebcaab3375cc02624ffd9de9998b3fdb20e1f5f
1 #ifndef _X86_64_PGALLOC_H
2 #define _X86_64_PGALLOC_H
4 #include <asm/processor.h>
5 #include <asm/fixmap.h>
6 #include <asm/pda.h>
7 #include <linux/threads.h>
8 #include <linux/mm.h>
10 #define pmd_populate_kernel(mm, pmd, pte) \
11 set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)))
12 #define pgd_populate(mm, pgd, pmd) \
13 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pmd)))
15 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
17 set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
20 extern __inline__ pmd_t *get_pmd(void)
22 return (pmd_t *)get_zeroed_page(GFP_KERNEL);
25 extern __inline__ void pmd_free(pmd_t *pmd)
27 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
28 free_page((unsigned long)pmd);
31 static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
33 return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
36 static inline pgd_t *pgd_alloc (struct mm_struct *mm)
38 return (pgd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
41 static inline void pgd_free (pgd_t *pgd)
43 BUG_ON((unsigned long)pgd & (PAGE_SIZE-1));
44 free_page((unsigned long)pgd);
47 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
49 return (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
52 static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
54 void *p = (void *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
55 if (!p)
56 return NULL;
57 return virt_to_page(p);
60 /* Should really implement gc for free page table pages. This could be
61 done with a reference count in struct page. */
63 extern __inline__ void pte_free_kernel(pte_t *pte)
65 BUG_ON((unsigned long)pte & (PAGE_SIZE-1));
66 free_page((unsigned long)pte);
69 extern inline void pte_free(struct page *pte)
71 __free_page(pte);
74 #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
75 #define __pmd_free_tlb(tlb,x) pmd_free(x)
77 #endif /* _X86_64_PGALLOC_H */