blob: 010f9cd0a672137d89ed4569549e78dd6868197e [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
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#include <linux/kernel.h>
6#include <linux/sched.h>
7#include <linux/mm.h>
David S. Miller3c936462006-01-31 18:30:27 -08008#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10#include <asm/spitfire.h>
11#include <asm/cpudata.h>
12#include <asm/cacheflush.h>
David S. Miller6a9b4902005-09-19 20:11:57 -070013#include <asm/page.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15/* Page table allocation/freeing. */
David S. Miller3c936462006-01-31 18:30:27 -080016extern kmem_cache_t *pgtable_cache;
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
David S. Miller3c936462006-01-31 18:30:27 -080018static inline pgd_t *pgd_alloc(struct mm_struct *mm)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019{
David S. Miller3c936462006-01-31 18:30:27 -080020 return kmem_cache_alloc(pgtable_cache, GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070021}
22
David S. Miller3c936462006-01-31 18:30:27 -080023static inline void pgd_free(pgd_t *pgd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024{
David S. Miller3c936462006-01-31 18:30:27 -080025 kmem_cache_free(pgtable_cache, pgd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026}
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
29
David S. Miller3c936462006-01-31 18:30:27 -080030static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031{
David S. Miller3c936462006-01-31 18:30:27 -080032 return kmem_cache_alloc(pgtable_cache,
33 GFP_KERNEL|__GFP_REPEAT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070034}
35
David S. Miller3c936462006-01-31 18:30:27 -080036static inline void pmd_free(pmd_t *pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037{
David S. Miller3c936462006-01-31 18:30:27 -080038 kmem_cache_free(pgtable_cache, pmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039}
40
David S. Miller3c936462006-01-31 18:30:27 -080041static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
42 unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043{
David S. Miller3c936462006-01-31 18:30:27 -080044 return kmem_cache_alloc(pgtable_cache,
45 GFP_KERNEL|__GFP_REPEAT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046}
47
David S. Miller3c936462006-01-31 18:30:27 -080048static inline struct page *pte_alloc_one(struct mm_struct *mm,
49 unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
David S. Miller3c936462006-01-31 18:30:27 -080051 return virt_to_page(pte_alloc_one_kernel(mm, address));
Linus Torvalds1da177e2005-04-16 15:20:36 -070052}
David S. Miller3c936462006-01-31 18:30:27 -080053
54static inline void pte_free_kernel(pte_t *pte)
55{
56 kmem_cache_free(pgtable_cache, pte);
57}
58
59static inline void pte_free(struct page *ptepage)
60{
61 pte_free_kernel(page_address(ptepage));
62}
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65#define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE)
66#define pmd_populate(MM,PMD,PTE_PAGE) \
67 pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE))
68
David S. Miller3c936462006-01-31 18:30:27 -080069#define check_pgt_cache() do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71#endif /* _SPARC64_PGALLOC_H */