aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mm/init.c')
-rw-r--r--arch/arm/mm/init.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 3a7279c1ce5e..40940d7ce4ff 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -15,6 +15,7 @@
15#include <linux/mman.h> 15#include <linux/mman.h>
16#include <linux/nodemask.h> 16#include <linux/nodemask.h>
17#include <linux/initrd.h> 17#include <linux/initrd.h>
18#include <linux/sort.h>
18#include <linux/highmem.h> 19#include <linux/highmem.h>
19 20
20#include <asm/mach-types.h> 21#include <asm/mach-types.h>
@@ -349,12 +350,43 @@ static void __init bootmem_free_node(int node, struct meminfo *mi)
349 free_area_init_node(node, zone_size, min, zhole_size); 350 free_area_init_node(node, zone_size, min, zhole_size);
350} 351}
351 352
353#ifndef CONFIG_SPARSEMEM
354int pfn_valid(unsigned long pfn)
355{
356 struct meminfo *mi = &meminfo;
357 unsigned int left = 0, right = mi->nr_banks;
358
359 do {
360 unsigned int mid = (right + left) / 2;
361 struct membank *bank = &mi->bank[mid];
362
363 if (pfn < bank_pfn_start(bank))
364 right = mid;
365 else if (pfn >= bank_pfn_end(bank))
366 left = mid + 1;
367 else
368 return 1;
369 } while (left < right);
370 return 0;
371}
372EXPORT_SYMBOL(pfn_valid);
373#endif
374
375static int __init meminfo_cmp(const void *_a, const void *_b)
376{
377 const struct membank *a = _a, *b = _b;
378 long cmp = bank_pfn_start(a) - bank_pfn_start(b);
379 return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
380}
381
352void __init bootmem_init(void) 382void __init bootmem_init(void)
353{ 383{
354 struct meminfo *mi = &meminfo; 384 struct meminfo *mi = &meminfo;
355 unsigned long min, max_low, max_high; 385 unsigned long min, max_low, max_high;
356 int node, initrd_node; 386 int node, initrd_node;
357 387
388 sort(&mi->bank, mi->nr_banks, sizeof(mi->bank[0]), meminfo_cmp, NULL);
389
358 /* 390 /*
359 * Locate which node contains the ramdisk image, if any. 391 * Locate which node contains the ramdisk image, if any.
360 */ 392 */
@@ -451,7 +483,7 @@ free_memmap(int node, unsigned long start_pfn, unsigned long end_pfn)
451 /* 483 /*
452 * Convert start_pfn/end_pfn to a struct page pointer. 484 * Convert start_pfn/end_pfn to a struct page pointer.
453 */ 485 */
454 start_pg = pfn_to_page(start_pfn); 486 start_pg = pfn_to_page(start_pfn - 1) + 1;
455 end_pg = pfn_to_page(end_pfn); 487 end_pg = pfn_to_page(end_pfn);
456 488
457 /* 489 /*
@@ -564,8 +596,8 @@ void __init mem_init(void)
564 596
565 printk(KERN_NOTICE "Memory: %luKB available (%dK code, " 597 printk(KERN_NOTICE "Memory: %luKB available (%dK code, "
566 "%dK data, %dK init, %luK highmem)\n", 598 "%dK data, %dK init, %luK highmem)\n",
567 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10), 599 nr_free_pages() << (PAGE_SHIFT-10), codesize >> 10,
568 codesize >> 10, datasize >> 10, initsize >> 10, 600 datasize >> 10, initsize >> 10,
569 (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))); 601 (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
570 602
571 if (PAGE_SIZE >= 16384 && num_physpages <= 128) { 603 if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
@@ -581,6 +613,14 @@ void __init mem_init(void)
581 613
582void free_initmem(void) 614void free_initmem(void)
583{ 615{
616#ifdef CONFIG_HAVE_TCM
617 extern char *__tcm_start, *__tcm_end;
618
619 totalram_pages += free_area(__phys_to_pfn(__pa(__tcm_start)),
620 __phys_to_pfn(__pa(__tcm_end)),
621 "TCM link");
622#endif
623
584 if (!machine_is_integrator() && !machine_is_cintegrator()) 624 if (!machine_is_integrator() && !machine_is_cintegrator())
585 totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)), 625 totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)),
586 __phys_to_pfn(__pa(__init_end)), 626 __phys_to_pfn(__pa(__init_end)),