1/* sun3_pgalloc.h -- 2 * reorganization around 2.3.39, routines moved from sun3_pgtable.h 3 * 4 * 5 * 02/27/2002 -- Modified to support "highpte" implementation in 2.5.5 (Sam) 6 * 7 * moved 1/26/2000 Sam Creasey 8 */ 9 10#ifndef _SUN3_PGALLOC_H 11#define _SUN3_PGALLOC_H 12 13#include <asm/tlb.h> 14 15/* erm, now that it's compiling, what do we do with it? */ 16#define _KERNPG_TABLE 0 17 18extern const char bad_pmd_string[]; 19 20#define pmd_alloc_one(mm,address) ({ BUG(); ((pmd_t *)2); }) 21 22 23static inline void pte_free_kernel(pte_t * pte) 24{ 25 free_page((unsigned long) pte); 26} 27 28static inline void pte_free(struct page *page) 29{ 30 __free_page(page); 31} 32 33#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) 34 35static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 36 unsigned long address) 37{ 38 unsigned long page = __get_free_page(GFP_KERNEL|__GFP_REPEAT); 39 40 if (!page) 41 return NULL; 42 43 memset((void *)page, 0, PAGE_SIZE); 44 return (pte_t *) (page); 45} 46 47static inline struct page *pte_alloc_one(struct mm_struct *mm, 48 unsigned long address) 49{ 50 struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0); 51 52 if (page == NULL) 53 return NULL; 54 55 clear_highpage(page); 56 return page; 57 58} 59 60static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) 61{ 62 pmd_val(*pmd) = __pa((unsigned long)pte); 63} 64 65static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page) 66{ 67 pmd_val(*pmd) = __pa((unsigned long)page_address(page)); 68} 69 70/* 71 * allocating and freeing a pmd is trivial: the 1-entry pmd is 72 * inside the pgd, so has no extra memory associated with it. 73 */ 74#define pmd_free(x) do { } while (0) 75#define __pmd_free_tlb(tlb, x) do { } while (0) 76 77static inline void pgd_free(pgd_t * pgd) 78{ 79 free_page((unsigned long) pgd); 80} 81 82static inline pgd_t * pgd_alloc(struct mm_struct *mm) 83{ 84 pgd_t *new_pgd; 85 86 new_pgd = (pgd_t *)get_zeroed_page(GFP_KERNEL); 87 memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE); 88 memset(new_pgd, 0, (PAGE_OFFSET >> PGDIR_SHIFT)); 89 return new_pgd; 90} 91 92#define pgd_populate(mm, pmd, pte) BUG() 93 94#endif /* SUN3_PGALLOC_H */ 95