Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_PGALLOC_H |
| 2 | #define _ASM_POWERPC_PGALLOC_H |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 3 | #ifdef __KERNEL__ |
Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 4 | |
Kumar Gala | 0186f47 | 2008-11-19 12:50:04 +0000 | [diff] [blame] | 5 | #include <linux/mm.h> |
| 6 | |
| 7 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
| 8 | { |
| 9 | free_page((unsigned long)pte); |
| 10 | } |
| 11 | |
| 12 | static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage) |
| 13 | { |
| 14 | pgtable_page_dtor(ptepage); |
| 15 | __free_page(ptepage); |
| 16 | } |
| 17 | |
| 18 | typedef struct pgtable_free { |
| 19 | unsigned long val; |
| 20 | } pgtable_free_t; |
| 21 | |
| 22 | #define PGF_CACHENUM_MASK 0x7 |
| 23 | |
| 24 | static inline pgtable_free_t pgtable_free_cache(void *p, int cachenum, |
| 25 | unsigned long mask) |
| 26 | { |
| 27 | BUG_ON(cachenum > PGF_CACHENUM_MASK); |
| 28 | |
| 29 | return (pgtable_free_t){.val = ((unsigned long) p & ~mask) | cachenum}; |
| 30 | } |
| 31 | |
David Gibson | f88df14 | 2007-04-30 16:30:56 +1000 | [diff] [blame] | 32 | #ifdef CONFIG_PPC64 |
| 33 | #include <asm/pgalloc-64.h> |
Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 34 | #else |
David Gibson | f88df14 | 2007-04-30 16:30:56 +1000 | [diff] [blame] | 35 | #include <asm/pgalloc-32.h> |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 36 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Kumar Gala | 0186f47 | 2008-11-19 12:50:04 +0000 | [diff] [blame] | 38 | extern void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf); |
| 39 | |
| 40 | #ifdef CONFIG_SMP |
| 41 | #define __pte_free_tlb(tlb,ptepage) \ |
| 42 | do { \ |
| 43 | pgtable_page_dtor(ptepage); \ |
| 44 | pgtable_free_tlb(tlb, pgtable_free_cache(page_address(ptepage), \ |
| 45 | PTE_NONCACHE_NUM, PTE_TABLE_SIZE-1)); \ |
| 46 | } while (0) |
| 47 | #else |
| 48 | #define __pte_free_tlb(tlb, pte) pte_free((tlb)->mm, (pte)) |
| 49 | #endif |
| 50 | |
| 51 | |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 52 | #endif /* __KERNEL__ */ |
Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 53 | #endif /* _ASM_POWERPC_PGALLOC_H */ |