diff options
Diffstat (limited to 'arch/xtensa/mm/init.c')
-rw-r--r-- | arch/xtensa/mm/init.c | 78 |
1 files changed, 10 insertions, 68 deletions
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c index 34163cfaaffc..427e14fa43c5 100644 --- a/arch/xtensa/mm/init.c +++ b/arch/xtensa/mm/init.c | |||
@@ -24,15 +24,8 @@ | |||
24 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | 26 | ||
27 | #include <asm/pgtable.h> | ||
28 | #include <asm/bootparam.h> | 27 | #include <asm/bootparam.h> |
29 | #include <asm/mmu_context.h> | ||
30 | #include <asm/tlb.h> | ||
31 | #include <asm/page.h> | 28 | #include <asm/page.h> |
32 | #include <asm/pgalloc.h> | ||
33 | |||
34 | |||
35 | DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); | ||
36 | 29 | ||
37 | /* References to section boundaries */ | 30 | /* References to section boundaries */ |
38 | 31 | ||
@@ -130,7 +123,8 @@ void __init bootmem_init(void) | |||
130 | 123 | ||
131 | /* Find an area to use for the bootmem bitmap. */ | 124 | /* Find an area to use for the bootmem bitmap. */ |
132 | 125 | ||
133 | bootmap_size = bootmem_bootmap_pages(max_low_pfn) << PAGE_SHIFT; | 126 | bootmap_size = bootmem_bootmap_pages(max_low_pfn - min_low_pfn); |
127 | bootmap_size <<= PAGE_SHIFT; | ||
134 | bootmap_start = ~0; | 128 | bootmap_start = ~0; |
135 | 129 | ||
136 | for (i=0; i<sysmem.nr_banks; i++) | 130 | for (i=0; i<sysmem.nr_banks; i++) |
@@ -145,8 +139,9 @@ void __init bootmem_init(void) | |||
145 | /* Reserve the bootmem bitmap area */ | 139 | /* Reserve the bootmem bitmap area */ |
146 | 140 | ||
147 | mem_reserve(bootmap_start, bootmap_start + bootmap_size, 1); | 141 | mem_reserve(bootmap_start, bootmap_start + bootmap_size, 1); |
148 | bootmap_size = init_bootmem_node(NODE_DATA(0), min_low_pfn, | 142 | bootmap_size = init_bootmem_node(NODE_DATA(0), |
149 | bootmap_start >> PAGE_SHIFT, | 143 | bootmap_start >> PAGE_SHIFT, |
144 | min_low_pfn, | ||
150 | max_low_pfn); | 145 | max_low_pfn); |
151 | 146 | ||
152 | /* Add all remaining memory pieces into the bootmem map */ | 147 | /* Add all remaining memory pieces into the bootmem map */ |
@@ -158,14 +153,14 @@ void __init bootmem_init(void) | |||
158 | } | 153 | } |
159 | 154 | ||
160 | 155 | ||
161 | void __init paging_init(void) | 156 | void __init zones_init(void) |
162 | { | 157 | { |
163 | unsigned long zones_size[MAX_NR_ZONES]; | 158 | unsigned long zones_size[MAX_NR_ZONES]; |
164 | int i; | 159 | int i; |
165 | 160 | ||
166 | /* All pages are DMA-able, so we put them all in the DMA zone. */ | 161 | /* All pages are DMA-able, so we put them all in the DMA zone. */ |
167 | 162 | ||
168 | zones_size[ZONE_DMA] = max_low_pfn; | 163 | zones_size[ZONE_DMA] = max_low_pfn - ARCH_PFN_OFFSET; |
169 | for (i = 1; i < MAX_NR_ZONES; i++) | 164 | for (i = 1; i < MAX_NR_ZONES; i++) |
170 | zones_size[i] = 0; | 165 | zones_size[i] = 0; |
171 | 166 | ||
@@ -173,40 +168,7 @@ void __init paging_init(void) | |||
173 | zones_size[ZONE_HIGHMEM] = max_pfn - max_low_pfn; | 168 | zones_size[ZONE_HIGHMEM] = max_pfn - max_low_pfn; |
174 | #endif | 169 | #endif |
175 | 170 | ||
176 | /* Initialize the kernel's page tables. */ | 171 | free_area_init_node(0, zones_size, ARCH_PFN_OFFSET, NULL); |
177 | |||
178 | memset(swapper_pg_dir, 0, PAGE_SIZE); | ||
179 | |||
180 | free_area_init(zones_size); | ||
181 | } | ||
182 | |||
183 | /* | ||
184 | * Flush the mmu and reset associated register to default values. | ||
185 | */ | ||
186 | |||
187 | void __init init_mmu (void) | ||
188 | { | ||
189 | /* Writing zeros to the <t>TLBCFG special registers ensure | ||
190 | * that valid values exist in the register. For existing | ||
191 | * PGSZID<w> fields, zero selects the first element of the | ||
192 | * page-size array. For nonexistent PGSZID<w> fields, zero is | ||
193 | * the best value to write. Also, when changing PGSZID<w> | ||
194 | * fields, the corresponding TLB must be flushed. | ||
195 | */ | ||
196 | set_itlbcfg_register (0); | ||
197 | set_dtlbcfg_register (0); | ||
198 | flush_tlb_all (); | ||
199 | |||
200 | /* Set rasid register to a known value. */ | ||
201 | |||
202 | set_rasid_register (ASID_USER_FIRST); | ||
203 | |||
204 | /* Set PTEVADDR special register to the start of the page | ||
205 | * table, which is in kernel mappable space (ie. not | ||
206 | * statically mapped). This register's value is undefined on | ||
207 | * reset. | ||
208 | */ | ||
209 | set_ptevaddr_register (PGTABLE_START); | ||
210 | } | 172 | } |
211 | 173 | ||
212 | /* | 174 | /* |
@@ -218,8 +180,8 @@ void __init mem_init(void) | |||
218 | unsigned long codesize, reservedpages, datasize, initsize; | 180 | unsigned long codesize, reservedpages, datasize, initsize; |
219 | unsigned long highmemsize, tmp, ram; | 181 | unsigned long highmemsize, tmp, ram; |
220 | 182 | ||
221 | max_mapnr = num_physpages = max_low_pfn; | 183 | max_mapnr = num_physpages = max_low_pfn - ARCH_PFN_OFFSET; |
222 | high_memory = (void *) __va(max_mapnr << PAGE_SHIFT); | 184 | high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); |
223 | highmemsize = 0; | 185 | highmemsize = 0; |
224 | 186 | ||
225 | #ifdef CONFIG_HIGHMEM | 187 | #ifdef CONFIG_HIGHMEM |
@@ -229,7 +191,7 @@ void __init mem_init(void) | |||
229 | totalram_pages += free_all_bootmem(); | 191 | totalram_pages += free_all_bootmem(); |
230 | 192 | ||
231 | reservedpages = ram = 0; | 193 | reservedpages = ram = 0; |
232 | for (tmp = 0; tmp < max_low_pfn; tmp++) { | 194 | for (tmp = 0; tmp < max_mapnr; tmp++) { |
233 | ram++; | 195 | ram++; |
234 | if (PageReserved(mem_map+tmp)) | 196 | if (PageReserved(mem_map+tmp)) |
235 | reservedpages++; | 197 | reservedpages++; |
@@ -279,23 +241,3 @@ void free_initmem(void) | |||
279 | printk("Freeing unused kernel memory: %dk freed\n", | 241 | printk("Freeing unused kernel memory: %dk freed\n", |
280 | (&__init_end - &__init_begin) >> 10); | 242 | (&__init_end - &__init_begin) >> 10); |
281 | } | 243 | } |
282 | |||
283 | struct kmem_cache *pgtable_cache __read_mostly; | ||
284 | |||
285 | static void pgd_ctor(void* addr) | ||
286 | { | ||
287 | pte_t* ptep = (pte_t*)addr; | ||
288 | int i; | ||
289 | |||
290 | for (i = 0; i < 1024; i++, ptep++) | ||
291 | pte_clear(NULL, 0, ptep); | ||
292 | |||
293 | } | ||
294 | |||
295 | void __init pgtable_cache_init(void) | ||
296 | { | ||
297 | pgtable_cache = kmem_cache_create("pgd", | ||
298 | PAGE_SIZE, PAGE_SIZE, | ||
299 | SLAB_HWCACHE_ALIGN, | ||
300 | pgd_ctor); | ||
301 | } | ||