blob: 12e4a273bd43adf54f6f12901ff1912305e6a0ce [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $Id: pgalloc.h,v 1.30 2001/12/21 04:56:17 davem Exp $ */
2#ifndef _SPARC64_PGALLOC_H
3#define _SPARC64_PGALLOC_H
4
5#include <linux/config.h>
6#include <linux/kernel.h>
7#include <linux/sched.h>
8#include <linux/mm.h>
David S. Miller3c936462006-01-31 18:30:27 -08009#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11#include <asm/spitfire.h>
12#include <asm/cpudata.h>
13#include <asm/cacheflush.h>
David S. Miller6a9b4902005-09-19 20:11:57 -070014#include <asm/page.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16/* Page table allocation/freeing. */
David S. Miller3c936462006-01-31 18:30:27 -080017extern kmem_cache_t *pgtable_cache;
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
David S. Miller3c936462006-01-31 18:30:27 -080019static inline pgd_t *pgd_alloc(struct mm_struct *mm)
Linus Torvalds1da177e2005-04-16 15:20:36 -070020{
David S. Miller3c936462006-01-31 18:30:27 -080021 return kmem_cache_alloc(pgtable_cache, GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070022}
23
David S. Miller3c936462006-01-31 18:30:27 -080024static inline void pgd_free(pgd_t *pgd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025{
David S. Miller3c936462006-01-31 18:30:27 -080026 kmem_cache_free(pgtable_cache, pgd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070027}
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
30
David S. Miller3c936462006-01-31 18:30:27 -080031static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070032{
David S. Miller3c936462006-01-31 18:30:27 -080033 return kmem_cache_alloc(pgtable_cache,
34 GFP_KERNEL|__GFP_REPEAT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070035}
36
David S. Miller3c936462006-01-31 18:30:27 -080037static inline void pmd_free(pmd_t *pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070038{
David S. Miller3c936462006-01-31 18:30:27 -080039 kmem_cache_free(pgtable_cache, pmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040}
41
David S. Miller3c936462006-01-31 18:30:27 -080042static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
43 unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044{
David S. Miller3c936462006-01-31 18:30:27 -080045 return kmem_cache_alloc(pgtable_cache,
46 GFP_KERNEL|__GFP_REPEAT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047}
48
David S. Miller3c936462006-01-31 18:30:27 -080049static inline struct page *pte_alloc_one(struct mm_struct *mm,
50 unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051{
David S. Miller3c936462006-01-31 18:30:27 -080052 return virt_to_page(pte_alloc_one_kernel(mm, address));
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
David S. Miller3c936462006-01-31 18:30:27 -080054
55static inline void pte_free_kernel(pte_t *pte)
56{
57 kmem_cache_free(pgtable_cache, pte);
58}
59
60static inline void pte_free(struct page *ptepage)
61{
62 pte_free_kernel(page_address(ptepage));
63}
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66#define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE)
67#define pmd_populate(MM,PMD,PTE_PAGE) \
68 pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE))
69
David S. Miller3c936462006-01-31 18:30:27 -080070#define check_pgt_cache() do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72#endif /* _SPARC64_PGALLOC_H */