]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/arch/arm/mm/init.c | |
3 | * | |
90072059 | 4 | * Copyright (C) 1995-2005 Russell King |
1da177e4 LT |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 as | |
8 | * published by the Free Software Foundation. | |
9 | */ | |
1da177e4 LT |
10 | #include <linux/kernel.h> |
11 | #include <linux/errno.h> | |
1da177e4 LT |
12 | #include <linux/swap.h> |
13 | #include <linux/init.h> | |
14 | #include <linux/bootmem.h> | |
15 | #include <linux/mman.h> | |
16 | #include <linux/nodemask.h> | |
17 | #include <linux/initrd.h> | |
3835f6cb | 18 | #include <linux/highmem.h> |
1da177e4 LT |
19 | |
20 | #include <asm/mach-types.h> | |
37efe642 | 21 | #include <asm/sections.h> |
1da177e4 | 22 | #include <asm/setup.h> |
74d02fb9 | 23 | #include <asm/sizes.h> |
1da177e4 LT |
24 | #include <asm/tlb.h> |
25 | ||
26 | #include <asm/mach/arch.h> | |
27 | #include <asm/mach/map.h> | |
28 | ||
1b2e2b73 RK |
29 | #include "mm.h" |
30 | ||
012d1f4a RK |
31 | static unsigned long phys_initrd_start __initdata = 0; |
32 | static unsigned long phys_initrd_size __initdata = 0; | |
33 | ||
34 | static void __init early_initrd(char **p) | |
35 | { | |
36 | unsigned long start, size; | |
37 | ||
38 | start = memparse(*p, p); | |
39 | if (**p == ',') { | |
40 | size = memparse((*p) + 1, p); | |
41 | ||
42 | phys_initrd_start = start; | |
43 | phys_initrd_size = size; | |
44 | } | |
45 | } | |
46 | __early_param("initrd=", early_initrd); | |
47 | ||
48 | static int __init parse_tag_initrd(const struct tag *tag) | |
49 | { | |
50 | printk(KERN_WARNING "ATAG_INITRD is deprecated; " | |
51 | "please update your bootloader.\n"); | |
52 | phys_initrd_start = __virt_to_phys(tag->u.initrd.start); | |
53 | phys_initrd_size = tag->u.initrd.size; | |
54 | return 0; | |
55 | } | |
56 | ||
57 | __tagtable(ATAG_INITRD, parse_tag_initrd); | |
58 | ||
59 | static int __init parse_tag_initrd2(const struct tag *tag) | |
60 | { | |
61 | phys_initrd_start = tag->u.initrd.start; | |
62 | phys_initrd_size = tag->u.initrd.size; | |
63 | return 0; | |
64 | } | |
65 | ||
66 | __tagtable(ATAG_INITRD2, parse_tag_initrd2); | |
1da177e4 LT |
67 | |
68 | /* | |
4b5f32ce NP |
69 | * This keeps memory configuration data used by a couple memory |
70 | * initialization functions, as well as show_mem() for the skipping | |
71 | * of holes in the memory map. It is populated by arm_add_memory(). | |
1da177e4 | 72 | */ |
4b5f32ce | 73 | struct meminfo meminfo; |
5e709827 | 74 | |
1da177e4 LT |
75 | void show_mem(void) |
76 | { | |
77 | int free = 0, total = 0, reserved = 0; | |
5e709827 RL |
78 | int shared = 0, cached = 0, slab = 0, node, i; |
79 | struct meminfo * mi = &meminfo; | |
1da177e4 LT |
80 | |
81 | printk("Mem-info:\n"); | |
82 | show_free_areas(); | |
1da177e4 | 83 | for_each_online_node(node) { |
204ecae4 | 84 | pg_data_t *n = NODE_DATA(node); |
b7a69ac3 | 85 | struct page *map = pgdat_page_nr(n, 0) - n->node_start_pfn; |
204ecae4 | 86 | |
5e709827 | 87 | for_each_nodebank (i,mi,node) { |
d2a38ef9 | 88 | struct membank *bank = &mi->bank[i]; |
5e709827 RL |
89 | unsigned int pfn1, pfn2; |
90 | struct page *page, *end; | |
91 | ||
d2a38ef9 RK |
92 | pfn1 = bank_pfn_start(bank); |
93 | pfn2 = bank_pfn_end(bank); | |
5e709827 | 94 | |
204ecae4 RK |
95 | page = map + pfn1; |
96 | end = map + pfn2; | |
5e709827 RL |
97 | |
98 | do { | |
99 | total++; | |
100 | if (PageReserved(page)) | |
101 | reserved++; | |
102 | else if (PageSwapCache(page)) | |
103 | cached++; | |
104 | else if (PageSlab(page)) | |
105 | slab++; | |
106 | else if (!page_count(page)) | |
107 | free++; | |
108 | else | |
109 | shared += page_count(page) - 1; | |
110 | page++; | |
111 | } while (page < end); | |
112 | } | |
1da177e4 LT |
113 | } |
114 | ||
115 | printk("%d pages of RAM\n", total); | |
116 | printk("%d free pages\n", free); | |
117 | printk("%d reserved pages\n", reserved); | |
118 | printk("%d slab pages\n", slab); | |
119 | printk("%d pages shared\n", shared); | |
120 | printk("%d pages swap cached\n", cached); | |
121 | } | |
122 | ||
dde5828f RK |
123 | static void __init find_node_limits(int node, struct meminfo *mi, |
124 | unsigned long *min, unsigned long *max_low, unsigned long *max_high) | |
125 | { | |
126 | int i; | |
127 | ||
128 | *min = -1UL; | |
129 | *max_low = *max_high = 0; | |
130 | ||
131 | for_each_nodebank(i, mi, node) { | |
132 | struct membank *bank = &mi->bank[i]; | |
133 | unsigned long start, end; | |
134 | ||
135 | start = bank_pfn_start(bank); | |
136 | end = bank_pfn_end(bank); | |
137 | ||
138 | if (*min > start) | |
139 | *min = start; | |
140 | if (*max_high < end) | |
141 | *max_high = end; | |
142 | if (bank->highmem) | |
143 | continue; | |
144 | if (*max_low < end) | |
145 | *max_low = end; | |
146 | } | |
147 | } | |
148 | ||
1da177e4 LT |
149 | /* |
150 | * FIXME: We really want to avoid allocating the bootmap bitmap | |
151 | * over the top of the initrd. Hopefully, this is located towards | |
152 | * the start of a bank, so if we allocate the bootmap bitmap at | |
153 | * the end, we won't clash. | |
154 | */ | |
155 | static unsigned int __init | |
156 | find_bootmap_pfn(int node, struct meminfo *mi, unsigned int bootmap_pages) | |
157 | { | |
d2a38ef9 | 158 | unsigned int start_pfn, i, bootmap_pfn; |
1da177e4 | 159 | |
37efe642 | 160 | start_pfn = PAGE_ALIGN(__pa(_end)) >> PAGE_SHIFT; |
1da177e4 LT |
161 | bootmap_pfn = 0; |
162 | ||
d2a38ef9 RK |
163 | for_each_nodebank(i, mi, node) { |
164 | struct membank *bank = &mi->bank[i]; | |
1da177e4 LT |
165 | unsigned int start, end; |
166 | ||
d2a38ef9 RK |
167 | start = bank_pfn_start(bank); |
168 | end = bank_pfn_end(bank); | |
1da177e4 LT |
169 | |
170 | if (end < start_pfn) | |
171 | continue; | |
172 | ||
173 | if (start < start_pfn) | |
174 | start = start_pfn; | |
175 | ||
176 | if (end <= start) | |
177 | continue; | |
178 | ||
179 | if (end - start >= bootmap_pages) { | |
180 | bootmap_pfn = start; | |
181 | break; | |
182 | } | |
183 | } | |
184 | ||
185 | if (bootmap_pfn == 0) | |
186 | BUG(); | |
187 | ||
188 | return bootmap_pfn; | |
189 | } | |
190 | ||
1da177e4 LT |
191 | static int __init check_initrd(struct meminfo *mi) |
192 | { | |
193 | int initrd_node = -2; | |
194 | #ifdef CONFIG_BLK_DEV_INITRD | |
195 | unsigned long end = phys_initrd_start + phys_initrd_size; | |
196 | ||
197 | /* | |
198 | * Make sure that the initrd is within a valid area of | |
199 | * memory. | |
200 | */ | |
201 | if (phys_initrd_size) { | |
202 | unsigned int i; | |
203 | ||
204 | initrd_node = -1; | |
205 | ||
206 | for (i = 0; i < mi->nr_banks; i++) { | |
d2a38ef9 RK |
207 | struct membank *bank = &mi->bank[i]; |
208 | if (bank_phys_start(bank) <= phys_initrd_start && | |
209 | end <= bank_phys_end(bank)) | |
210 | initrd_node = bank->node; | |
1da177e4 LT |
211 | } |
212 | } | |
213 | ||
214 | if (initrd_node == -1) { | |
b962a286 | 215 | printk(KERN_ERR "INITRD: 0x%08lx+0x%08lx extends beyond " |
1da177e4 | 216 | "physical memory - disabling initrd\n", |
b962a286 | 217 | phys_initrd_start, phys_initrd_size); |
1da177e4 LT |
218 | phys_initrd_start = phys_initrd_size = 0; |
219 | } | |
220 | #endif | |
221 | ||
222 | return initrd_node; | |
223 | } | |
224 | ||
456335e2 RK |
225 | static inline void map_memory_bank(struct membank *bank) |
226 | { | |
d111e8f9 | 227 | #ifdef CONFIG_MMU |
456335e2 RK |
228 | struct map_desc map; |
229 | ||
d2a38ef9 RK |
230 | map.pfn = bank_pfn_start(bank); |
231 | map.virtual = __phys_to_virt(bank_phys_start(bank)); | |
232 | map.length = bank_phys_size(bank); | |
456335e2 RK |
233 | map.type = MT_MEMORY; |
234 | ||
235 | create_mapping(&map); | |
d111e8f9 | 236 | #endif |
456335e2 RK |
237 | } |
238 | ||
dde5828f RK |
239 | static void __init bootmem_init_node(int node, struct meminfo *mi, |
240 | unsigned long start_pfn, unsigned long end_pfn) | |
1da177e4 | 241 | { |
dde5828f | 242 | unsigned long boot_pfn; |
90072059 RK |
243 | unsigned int boot_pages; |
244 | pg_data_t *pgdat; | |
245 | int i; | |
1da177e4 | 246 | |
90072059 | 247 | /* |
dde5828f | 248 | * Map the memory banks for this node. |
90072059 RK |
249 | */ |
250 | for_each_nodebank(i, mi, node) { | |
456335e2 | 251 | struct membank *bank = &mi->bank[i]; |
90072059 | 252 | |
dde5828f RK |
253 | if (!bank->highmem) |
254 | map_memory_bank(bank); | |
90072059 | 255 | } |
1da177e4 | 256 | |
90072059 RK |
257 | /* |
258 | * Allocate the bootmem bitmap page. | |
259 | */ | |
260 | boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn); | |
261 | boot_pfn = find_bootmap_pfn(node, mi, boot_pages); | |
1da177e4 | 262 | |
90072059 RK |
263 | /* |
264 | * Initialise the bootmem allocator for this node, handing the | |
265 | * memory banks over to bootmem. | |
266 | */ | |
267 | node_set_online(node); | |
268 | pgdat = NODE_DATA(node); | |
269 | init_bootmem_node(pgdat, boot_pfn, start_pfn, end_pfn); | |
1da177e4 | 270 | |
d2a38ef9 RK |
271 | for_each_nodebank(i, mi, node) { |
272 | struct membank *bank = &mi->bank[i]; | |
dde5828f RK |
273 | if (!bank->highmem) |
274 | free_bootmem_node(pgdat, bank_phys_start(bank), bank_phys_size(bank)); | |
b7a69ac3 | 275 | memory_present(node, bank_pfn_start(bank), bank_pfn_end(bank)); |
d2a38ef9 | 276 | } |
90072059 RK |
277 | |
278 | /* | |
279 | * Reserve the bootmem bitmap for this node. | |
280 | */ | |
281 | reserve_bootmem_node(pgdat, boot_pfn << PAGE_SHIFT, | |
72a7fe39 | 282 | boot_pages << PAGE_SHIFT, BOOTMEM_DEFAULT); |
b7a69ac3 | 283 | } |
b962a286 | 284 | |
b7a69ac3 RK |
285 | static void __init bootmem_reserve_initrd(int node) |
286 | { | |
1da177e4 | 287 | #ifdef CONFIG_BLK_DEV_INITRD |
b7a69ac3 RK |
288 | pg_data_t *pgdat = NODE_DATA(node); |
289 | int res; | |
290 | ||
291 | res = reserve_bootmem_node(pgdat, phys_initrd_start, | |
292 | phys_initrd_size, BOOTMEM_EXCLUSIVE); | |
293 | ||
294 | if (res == 0) { | |
295 | initrd_start = __phys_to_virt(phys_initrd_start); | |
296 | initrd_end = initrd_start + phys_initrd_size; | |
297 | } else { | |
298 | printk(KERN_ERR | |
299 | "INITRD: 0x%08lx+0x%08lx overlaps in-use " | |
300 | "memory region - disabling initrd\n", | |
301 | phys_initrd_start, phys_initrd_size); | |
1da177e4 LT |
302 | } |
303 | #endif | |
b7a69ac3 RK |
304 | } |
305 | ||
306 | static void __init bootmem_free_node(int node, struct meminfo *mi) | |
307 | { | |
308 | unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES]; | |
dde5828f | 309 | unsigned long min, max_low, max_high; |
b7a69ac3 RK |
310 | int i; |
311 | ||
dde5828f | 312 | find_node_limits(node, mi, &min, &max_low, &max_high); |
1da177e4 | 313 | |
90072059 RK |
314 | /* |
315 | * initialise the zones within this node. | |
316 | */ | |
317 | memset(zone_size, 0, sizeof(zone_size)); | |
90072059 RK |
318 | |
319 | /* | |
320 | * The size of this node has already been determined. If we need | |
321 | * to do anything fancy with the allocation of this memory to the | |
322 | * zones, now is the time to do it. | |
323 | */ | |
dde5828f RK |
324 | zone_size[0] = max_low - min; |
325 | #ifdef CONFIG_HIGHMEM | |
326 | zone_size[ZONE_HIGHMEM] = max_high - max_low; | |
327 | #endif | |
90072059 RK |
328 | |
329 | /* | |
330 | * For each bank in this node, calculate the size of the holes. | |
331 | * holes = node_size - sum(bank_sizes_in_node) | |
332 | */ | |
dde5828f RK |
333 | memcpy(zhole_size, zone_size, sizeof(zhole_size)); |
334 | for_each_nodebank(i, mi, node) { | |
335 | int idx = 0; | |
336 | #ifdef CONFIG_HIGHMEM | |
337 | if (mi->bank[i].highmem) | |
338 | idx = ZONE_HIGHMEM; | |
339 | #endif | |
340 | zhole_size[idx] -= bank_pfn_size(&mi->bank[i]); | |
341 | } | |
90072059 RK |
342 | |
343 | /* | |
344 | * Adjust the sizes according to any special requirements for | |
345 | * this machine type. | |
346 | */ | |
347 | arch_adjust_zones(node, zone_size, zhole_size); | |
348 | ||
dde5828f | 349 | free_area_init_node(node, zone_size, min, zhole_size); |
1da177e4 LT |
350 | } |
351 | ||
4b5f32ce | 352 | void __init bootmem_init(void) |
1da177e4 | 353 | { |
4b5f32ce | 354 | struct meminfo *mi = &meminfo; |
dde5828f | 355 | unsigned long min, max_low, max_high; |
eca73214 | 356 | int node, initrd_node; |
1da177e4 | 357 | |
1da177e4 | 358 | /* |
90072059 | 359 | * Locate which node contains the ramdisk image, if any. |
1da177e4 | 360 | */ |
90072059 | 361 | initrd_node = check_initrd(mi); |
1da177e4 | 362 | |
dde5828f RK |
363 | max_low = max_high = 0; |
364 | ||
90072059 RK |
365 | /* |
366 | * Run through each node initialising the bootmem allocator. | |
367 | */ | |
368 | for_each_node(node) { | |
dde5828f RK |
369 | unsigned long node_low, node_high; |
370 | ||
371 | find_node_limits(node, mi, &min, &node_low, &node_high); | |
372 | ||
373 | if (node_low > max_low) | |
374 | max_low = node_low; | |
375 | if (node_high > max_high) | |
376 | max_high = node_high; | |
377 | ||
378 | /* | |
379 | * If there is no memory in this node, ignore it. | |
380 | * (We can't have nodes which have no lowmem) | |
381 | */ | |
382 | if (node_low == 0) | |
383 | continue; | |
384 | ||
385 | bootmem_init_node(node, mi, min, node_low); | |
1da177e4 | 386 | |
b7a69ac3 RK |
387 | /* |
388 | * Reserve any special node zero regions. | |
389 | */ | |
390 | if (node == 0) | |
391 | reserve_node_zero(NODE_DATA(node)); | |
392 | ||
393 | /* | |
394 | * If the initrd is in this node, reserve its memory. | |
395 | */ | |
396 | if (node == initrd_node) | |
397 | bootmem_reserve_initrd(node); | |
90072059 | 398 | } |
1da177e4 | 399 | |
b7a69ac3 RK |
400 | /* |
401 | * sparse_init() needs the bootmem allocator up and running. | |
402 | */ | |
403 | sparse_init(); | |
404 | ||
405 | /* | |
406 | * Now free memory in each node - free_area_init_node needs | |
407 | * the sparse mem_map arrays initialized by sparse_init() | |
408 | * for memmap_init_zone(), otherwise all PFNs are invalid. | |
409 | */ | |
410 | for_each_node(node) | |
411 | bootmem_free_node(node, mi); | |
412 | ||
dde5828f | 413 | high_memory = __va((max_low << PAGE_SHIFT) - 1) + 1; |
1da177e4 | 414 | |
90072059 RK |
415 | /* |
416 | * This doesn't seem to be used by the Linux memory manager any | |
417 | * more, but is used by ll_rw_block. If we can get rid of it, we | |
418 | * also get rid of some of the stuff above as well. | |
419 | * | |
420 | * Note: max_low_pfn and max_pfn reflect the number of _pages_ in | |
421 | * the system, not the maximum PFN. | |
422 | */ | |
dde5828f RK |
423 | max_low_pfn = max_low - PHYS_PFN_OFFSET; |
424 | max_pfn = max_high - PHYS_PFN_OFFSET; | |
90072059 | 425 | } |
1da177e4 | 426 | |
6db015e4 | 427 | static inline int free_area(unsigned long pfn, unsigned long end, char *s) |
1da177e4 | 428 | { |
6db015e4 | 429 | unsigned int pages = 0, size = (end - pfn) << (PAGE_SHIFT - 10); |
1da177e4 | 430 | |
6db015e4 NP |
431 | for (; pfn < end; pfn++) { |
432 | struct page *page = pfn_to_page(pfn); | |
1da177e4 | 433 | ClearPageReserved(page); |
7835e98b | 434 | init_page_count(page); |
6db015e4 NP |
435 | __free_page(page); |
436 | pages++; | |
1da177e4 LT |
437 | } |
438 | ||
439 | if (size && s) | |
440 | printk(KERN_INFO "Freeing %s memory: %dK\n", s, size); | |
6db015e4 NP |
441 | |
442 | return pages; | |
1da177e4 LT |
443 | } |
444 | ||
a013053d RK |
445 | static inline void |
446 | free_memmap(int node, unsigned long start_pfn, unsigned long end_pfn) | |
447 | { | |
448 | struct page *start_pg, *end_pg; | |
449 | unsigned long pg, pgend; | |
450 | ||
451 | /* | |
452 | * Convert start_pfn/end_pfn to a struct page pointer. | |
453 | */ | |
454 | start_pg = pfn_to_page(start_pfn); | |
455 | end_pg = pfn_to_page(end_pfn); | |
456 | ||
457 | /* | |
458 | * Convert to physical addresses, and | |
459 | * round start upwards and end downwards. | |
460 | */ | |
461 | pg = PAGE_ALIGN(__pa(start_pg)); | |
462 | pgend = __pa(end_pg) & PAGE_MASK; | |
463 | ||
464 | /* | |
465 | * If there are free pages between these, | |
466 | * free the section of the memmap array. | |
467 | */ | |
468 | if (pg < pgend) | |
469 | free_bootmem_node(NODE_DATA(node), pg, pgend - pg); | |
470 | } | |
471 | ||
472 | /* | |
473 | * The mem_map array can get very big. Free the unused area of the memory map. | |
474 | */ | |
475 | static void __init free_unused_memmap_node(int node, struct meminfo *mi) | |
476 | { | |
477 | unsigned long bank_start, prev_bank_end = 0; | |
478 | unsigned int i; | |
479 | ||
480 | /* | |
481 | * [FIXME] This relies on each bank being in address order. This | |
482 | * may not be the case, especially if the user has provided the | |
483 | * information on the command line. | |
484 | */ | |
90072059 | 485 | for_each_nodebank(i, mi, node) { |
d2a38ef9 RK |
486 | struct membank *bank = &mi->bank[i]; |
487 | ||
488 | bank_start = bank_pfn_start(bank); | |
a013053d RK |
489 | if (bank_start < prev_bank_end) { |
490 | printk(KERN_ERR "MEM: unordered memory banks. " | |
491 | "Not freeing memmap.\n"); | |
492 | break; | |
493 | } | |
494 | ||
495 | /* | |
496 | * If we had a previous bank, and there is a space | |
497 | * between the current bank and the previous, free it. | |
498 | */ | |
499 | if (prev_bank_end && prev_bank_end != bank_start) | |
500 | free_memmap(node, prev_bank_end, bank_start); | |
501 | ||
d2a38ef9 | 502 | prev_bank_end = bank_pfn_end(bank); |
a013053d RK |
503 | } |
504 | } | |
505 | ||
1da177e4 LT |
506 | /* |
507 | * mem_init() marks the free areas in the mem_map and tells us how much | |
508 | * memory is free. This is done after various parts of the system have | |
509 | * claimed their memory after the kernel image. | |
510 | */ | |
511 | void __init mem_init(void) | |
512 | { | |
6db015e4 | 513 | unsigned int codesize, datasize, initsize; |
1da177e4 LT |
514 | int i, node; |
515 | ||
1da177e4 | 516 | #ifndef CONFIG_DISCONTIGMEM |
3835f6cb | 517 | max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map; |
1da177e4 LT |
518 | #endif |
519 | ||
1da177e4 LT |
520 | /* this will put all unused low memory onto the freelists */ |
521 | for_each_online_node(node) { | |
522 | pg_data_t *pgdat = NODE_DATA(node); | |
523 | ||
a013053d RK |
524 | free_unused_memmap_node(node, &meminfo); |
525 | ||
1da177e4 LT |
526 | if (pgdat->node_spanned_pages != 0) |
527 | totalram_pages += free_all_bootmem_node(pgdat); | |
528 | } | |
529 | ||
530 | #ifdef CONFIG_SA1111 | |
531 | /* now that our DMA memory is actually so designated, we can free it */ | |
6db015e4 NP |
532 | totalram_pages += free_area(PHYS_PFN_OFFSET, |
533 | __phys_to_pfn(__pa(swapper_pg_dir)), NULL); | |
1da177e4 LT |
534 | #endif |
535 | ||
3835f6cb NP |
536 | #ifdef CONFIG_HIGHMEM |
537 | /* set highmem page free */ | |
538 | for_each_online_node(node) { | |
539 | for_each_nodebank (i, &meminfo, node) { | |
540 | unsigned long start = bank_pfn_start(&meminfo.bank[i]); | |
541 | unsigned long end = bank_pfn_end(&meminfo.bank[i]); | |
542 | if (start >= max_low_pfn + PHYS_PFN_OFFSET) | |
543 | totalhigh_pages += free_area(start, end, NULL); | |
544 | } | |
545 | } | |
546 | totalram_pages += totalhigh_pages; | |
547 | #endif | |
548 | ||
1da177e4 LT |
549 | /* |
550 | * Since our memory may not be contiguous, calculate the | |
551 | * real number of pages we have in this system | |
552 | */ | |
553 | printk(KERN_INFO "Memory:"); | |
1da177e4 LT |
554 | num_physpages = 0; |
555 | for (i = 0; i < meminfo.nr_banks; i++) { | |
d2a38ef9 RK |
556 | num_physpages += bank_pfn_size(&meminfo.bank[i]); |
557 | printk(" %ldMB", bank_phys_size(&meminfo.bank[i]) >> 20); | |
1da177e4 | 558 | } |
1da177e4 | 559 | printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT)); |
6db015e4 | 560 | |
37efe642 RK |
561 | codesize = _etext - _text; |
562 | datasize = _end - _data; | |
563 | initsize = __init_end - __init_begin; | |
6db015e4 | 564 | |
1da177e4 | 565 | printk(KERN_NOTICE "Memory: %luKB available (%dK code, " |
3835f6cb | 566 | "%dK data, %dK init, %luK highmem)\n", |
1da177e4 | 567 | (unsigned long) nr_free_pages() << (PAGE_SHIFT-10), |
3835f6cb NP |
568 | codesize >> 10, datasize >> 10, initsize >> 10, |
569 | (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))); | |
1da177e4 LT |
570 | |
571 | if (PAGE_SIZE >= 16384 && num_physpages <= 128) { | |
572 | extern int sysctl_overcommit_memory; | |
573 | /* | |
574 | * On a machine this small we won't get | |
575 | * anywhere without overcommit, so turn | |
576 | * it on by default. | |
577 | */ | |
578 | sysctl_overcommit_memory = OVERCOMMIT_ALWAYS; | |
579 | } | |
580 | } | |
581 | ||
582 | void free_initmem(void) | |
583 | { | |
6db015e4 | 584 | if (!machine_is_integrator() && !machine_is_cintegrator()) |
37efe642 RK |
585 | totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)), |
586 | __phys_to_pfn(__pa(__init_end)), | |
6db015e4 | 587 | "init"); |
1da177e4 LT |
588 | } |
589 | ||
590 | #ifdef CONFIG_BLK_DEV_INITRD | |
591 | ||
592 | static int keep_initrd; | |
593 | ||
594 | void free_initrd_mem(unsigned long start, unsigned long end) | |
595 | { | |
596 | if (!keep_initrd) | |
6db015e4 NP |
597 | totalram_pages += free_area(__phys_to_pfn(__pa(start)), |
598 | __phys_to_pfn(__pa(end)), | |
599 | "initrd"); | |
1da177e4 LT |
600 | } |
601 | ||
602 | static int __init keepinitrd_setup(char *__unused) | |
603 | { | |
604 | keep_initrd = 1; | |
605 | return 1; | |
606 | } | |
607 | ||
608 | __setup("keepinitrd", keepinitrd_setup); | |
609 | #endif |