diff options
Diffstat (limited to 'arch/blackfin/kernel/setup.c')
-rw-r--r-- | arch/blackfin/kernel/setup.c | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c index 2255c289a714..a871d8358246 100644 --- a/arch/blackfin/kernel/setup.c +++ b/arch/blackfin/kernel/setup.c | |||
@@ -547,11 +547,38 @@ static __init void memory_setup(void) | |||
547 | ); | 547 | ); |
548 | } | 548 | } |
549 | 549 | ||
550 | /* | ||
551 | * Find the lowest, highest page frame number we have available | ||
552 | */ | ||
553 | void __init find_min_max_pfn(void) | ||
554 | { | ||
555 | int i; | ||
556 | |||
557 | max_pfn = 0; | ||
558 | min_low_pfn = memory_end; | ||
559 | |||
560 | for (i = 0; i < bfin_memmap.nr_map; i++) { | ||
561 | unsigned long start, end; | ||
562 | /* RAM? */ | ||
563 | if (bfin_memmap.map[i].type != BFIN_MEMMAP_RAM) | ||
564 | continue; | ||
565 | start = PFN_UP(bfin_memmap.map[i].addr); | ||
566 | end = PFN_DOWN(bfin_memmap.map[i].addr + | ||
567 | bfin_memmap.map[i].size); | ||
568 | if (start >= end) | ||
569 | continue; | ||
570 | if (end > max_pfn) | ||
571 | max_pfn = end; | ||
572 | if (start < min_low_pfn) | ||
573 | min_low_pfn = start; | ||
574 | } | ||
575 | } | ||
576 | |||
550 | static __init void setup_bootmem_allocator(void) | 577 | static __init void setup_bootmem_allocator(void) |
551 | { | 578 | { |
552 | int bootmap_size; | 579 | int bootmap_size; |
553 | int i; | 580 | int i; |
554 | unsigned long min_pfn, max_pfn; | 581 | unsigned long start_pfn, end_pfn; |
555 | unsigned long curr_pfn, last_pfn, size; | 582 | unsigned long curr_pfn, last_pfn, size; |
556 | 583 | ||
557 | /* mark memory between memory_start and memory_end usable */ | 584 | /* mark memory between memory_start and memory_end usable */ |
@@ -561,8 +588,19 @@ static __init void setup_bootmem_allocator(void) | |||
561 | sanitize_memmap(bfin_memmap.map, &bfin_memmap.nr_map); | 588 | sanitize_memmap(bfin_memmap.map, &bfin_memmap.nr_map); |
562 | print_memory_map("boot memmap"); | 589 | print_memory_map("boot memmap"); |
563 | 590 | ||
564 | min_pfn = PAGE_OFFSET >> PAGE_SHIFT; | 591 | /* intialize globals in linux/bootmem.h */ |
565 | max_pfn = memory_end >> PAGE_SHIFT; | 592 | find_min_max_pfn(); |
593 | /* pfn of the last usable page frame */ | ||
594 | if (max_pfn > memory_end >> PAGE_SHIFT) | ||
595 | max_pfn = memory_end >> PAGE_SHIFT; | ||
596 | /* pfn of last page frame directly mapped by kernel */ | ||
597 | max_low_pfn = max_pfn; | ||
598 | /* pfn of the first usable page frame after kernel image*/ | ||
599 | if (min_low_pfn < memory_start >> PAGE_SHIFT) | ||
600 | min_low_pfn = memory_start >> PAGE_SHIFT; | ||
601 | |||
602 | start_pfn = PAGE_OFFSET >> PAGE_SHIFT; | ||
603 | end_pfn = memory_end >> PAGE_SHIFT; | ||
566 | 604 | ||
567 | /* | 605 | /* |
568 | * give all the memory to the bootmap allocator, tell it to put the | 606 | * give all the memory to the bootmap allocator, tell it to put the |
@@ -570,7 +608,7 @@ static __init void setup_bootmem_allocator(void) | |||
570 | */ | 608 | */ |
571 | bootmap_size = init_bootmem_node(NODE_DATA(0), | 609 | bootmap_size = init_bootmem_node(NODE_DATA(0), |
572 | memory_start >> PAGE_SHIFT, /* map goes here */ | 610 | memory_start >> PAGE_SHIFT, /* map goes here */ |
573 | min_pfn, max_pfn); | 611 | start_pfn, end_pfn); |
574 | 612 | ||
575 | /* register the memmap regions with the bootmem allocator */ | 613 | /* register the memmap regions with the bootmem allocator */ |
576 | for (i = 0; i < bfin_memmap.nr_map; i++) { | 614 | for (i = 0; i < bfin_memmap.nr_map; i++) { |
@@ -583,7 +621,7 @@ static __init void setup_bootmem_allocator(void) | |||
583 | * We are rounding up the start address of usable memory: | 621 | * We are rounding up the start address of usable memory: |
584 | */ | 622 | */ |
585 | curr_pfn = PFN_UP(bfin_memmap.map[i].addr); | 623 | curr_pfn = PFN_UP(bfin_memmap.map[i].addr); |
586 | if (curr_pfn >= max_pfn) | 624 | if (curr_pfn >= end_pfn) |
587 | continue; | 625 | continue; |
588 | /* | 626 | /* |
589 | * ... and at the end of the usable range downwards: | 627 | * ... and at the end of the usable range downwards: |
@@ -591,8 +629,8 @@ static __init void setup_bootmem_allocator(void) | |||
591 | last_pfn = PFN_DOWN(bfin_memmap.map[i].addr + | 629 | last_pfn = PFN_DOWN(bfin_memmap.map[i].addr + |
592 | bfin_memmap.map[i].size); | 630 | bfin_memmap.map[i].size); |
593 | 631 | ||
594 | if (last_pfn > max_pfn) | 632 | if (last_pfn > end_pfn) |
595 | last_pfn = max_pfn; | 633 | last_pfn = end_pfn; |
596 | 634 | ||
597 | /* | 635 | /* |
598 | * .. finally, did all the rounding and playing | 636 | * .. finally, did all the rounding and playing |