MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / asm-s390 / pgalloc.h
blob90308137c8e64175f4eaadf7a1226e7786939786
1 /*
2 * include/asm-s390/pgalloc.h
4 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Hartmut Penner (hp@de.ibm.com)
7 * Martin Schwidefsky (schwidefsky@de.ibm.com)
9 * Derived from "include/asm-i386/pgalloc.h"
10 * Copyright (C) 1994 Linus Torvalds
13 #ifndef _S390_PGALLOC_H
14 #define _S390_PGALLOC_H
16 #include <linux/config.h>
17 #include <asm/processor.h>
18 #include <linux/threads.h>
19 #include <linux/gfp.h>
20 #include <linux/mm.h>
22 #define check_pgt_cache() do {} while (0)
24 extern void diag10(unsigned long addr);
27 * Allocate and free page tables. The xxx_kernel() versions are
28 * used to allocate a kernel page table - this turns on ASN bits
29 * if any.
32 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
34 pgd_t *pgd;
35 int i;
37 #ifndef __s390x__
38 pgd = (pgd_t *) __get_free_pages(GFP_KERNEL,1);
39 if (pgd != NULL)
40 for (i = 0; i < USER_PTRS_PER_PGD; i++)
41 pmd_clear(pmd_offset(pgd + i, i*PGDIR_SIZE));
42 #else /* __s390x__ */
43 pgd = (pgd_t *) __get_free_pages(GFP_KERNEL,2);
44 if (pgd != NULL)
45 for (i = 0; i < PTRS_PER_PGD; i++)
46 pgd_clear(pgd + i);
47 #endif /* __s390x__ */
48 return pgd;
51 static inline void pgd_free(pgd_t *pgd)
53 #ifndef __s390x__
54 free_pages((unsigned long) pgd, 1);
55 #else /* __s390x__ */
56 free_pages((unsigned long) pgd, 2);
57 #endif /* __s390x__ */
60 #ifndef __s390x__
62 * page middle directory allocation/free routines.
63 * We use pmd cache only on s390x, so these are dummy routines. This
64 * code never triggers because the pgd will always be present.
66 #define pmd_alloc_one(mm,address) ({ BUG(); ((pmd_t *)2); })
67 #define pmd_free(x) do { } while (0)
68 #define __pmd_free_tlb(tlb,x) do { } while (0)
69 #define pgd_populate(mm, pmd, pte) BUG()
70 #else /* __s390x__ */
71 static inline pmd_t * pmd_alloc_one(struct mm_struct *mm, unsigned long vmaddr)
73 pmd_t *pmd;
74 int i;
76 pmd = (pmd_t *) __get_free_pages(GFP_KERNEL, 2);
77 if (pmd != NULL) {
78 for (i=0; i < PTRS_PER_PMD; i++)
79 pmd_clear(pmd+i);
81 return pmd;
84 static inline void pmd_free (pmd_t *pmd)
86 free_pages((unsigned long) pmd, 2);
89 #define __pmd_free_tlb(tlb,pmd) \
90 do { \
91 tlb_flush_mmu(tlb, 0, 0); \
92 pmd_free(pmd); \
93 } while (0)
95 static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
97 pgd_val(*pgd) = _PGD_ENTRY | __pa(pmd);
100 #endif /* __s390x__ */
102 static inline void
103 pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
105 #ifndef __s390x__
106 pmd_val(pmd[0]) = _PAGE_TABLE + __pa(pte);
107 pmd_val(pmd[1]) = _PAGE_TABLE + __pa(pte+256);
108 pmd_val(pmd[2]) = _PAGE_TABLE + __pa(pte+512);
109 pmd_val(pmd[3]) = _PAGE_TABLE + __pa(pte+768);
110 #else /* __s390x__ */
111 pmd_val(*pmd) = _PMD_ENTRY + __pa(pte);
112 pmd_val1(*pmd) = _PMD_ENTRY + __pa(pte+256);
113 #endif /* __s390x__ */
116 static inline void
117 pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page)
119 pmd_populate_kernel(mm, pmd, (pte_t *)((page-mem_map) << PAGE_SHIFT));
123 * page table entry allocation/free routines.
125 static inline pte_t *
126 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long vmaddr)
128 pte_t *pte;
129 int i;
131 pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
132 if (pte != NULL) {
133 for (i=0; i < PTRS_PER_PTE; i++)
134 pte_clear(pte+i);
136 return pte;
139 static inline struct page *
140 pte_alloc_one(struct mm_struct *mm, unsigned long vmaddr)
142 pte_t *pte = pte_alloc_one_kernel(mm, vmaddr);
143 if (pte)
144 return virt_to_page(pte);
145 return 0;
148 static inline void pte_free_kernel(pte_t *pte)
150 free_page((unsigned long) pte);
153 static inline void pte_free(struct page *pte)
155 __free_page(pte);
158 #define __pte_free_tlb(tlb,pte) tlb_remove_page(tlb,pte)
161 * This establishes kernel virtual mappings (e.g., as a result of a
162 * vmalloc call). Since s390-esame uses a separate kernel page table,
163 * there is nothing to do here... :)
165 #define set_pgdir(addr,entry) do { } while(0)
167 #endif /* _S390_PGALLOC_H */