diff options
author | bibo,mao <bibo.mao@intel.com> | 2006-12-06 20:14:06 -0500 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2006-12-06 20:14:06 -0500 |
commit | b5b2405706005cc7765f6ecd00965d29e93f090a (patch) | |
tree | 514860ebb7571fa7ee3d5f6eea8462793b992c0c /arch/i386/kernel/setup.c | |
parent | b2dff6a88cbed59d787a8ca7367c76ba385e1187 (diff) |
[PATCH] i386: Move e820/efi memmap walking code to e820.c
This patch moves e820/efi memmap table walking function from
setup.c to e820.c, also this patch adds extern declaration in
header file.
Signed-off-by: bibo,mao <bibo.mao@intel.com>
Signed-off-by: Andi Kleen <ak@suse.de>
arch/i386/kernel/e820.c | 115 +++++++++++++++++++++++++++++++++
arch/i386/kernel/setup.c | 118 -----------------------------------
include/asm-i386/e820.h | 2
arch/i386/kernel/e820.c | 115 +++++++++++++++++++++++++++++++++++++++++++++
arch/i386/kernel/setup.c | 118 -----------------------------------------------
include/asm-i386/e820.h | 2
3 files changed, 117 insertions(+), 118 deletions(-)
Diffstat (limited to 'arch/i386/kernel/setup.c')
-rw-r--r-- | arch/i386/kernel/setup.c | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index 3d808054fdf7..51ed015a1f35 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c | |||
@@ -94,12 +94,6 @@ unsigned int machine_submodel_id; | |||
94 | unsigned int BIOS_revision; | 94 | unsigned int BIOS_revision; |
95 | unsigned int mca_pentium_flag; | 95 | unsigned int mca_pentium_flag; |
96 | 96 | ||
97 | /* For PCI or other memory-mapped resources */ | ||
98 | unsigned long pci_mem_start = 0x10000000; | ||
99 | #ifdef CONFIG_PCI | ||
100 | EXPORT_SYMBOL(pci_mem_start); | ||
101 | #endif | ||
102 | |||
103 | /* Boot loader ID as an integer, for the benefit of proc_dointvec */ | 97 | /* Boot loader ID as an integer, for the benefit of proc_dointvec */ |
104 | int bootloader_type; | 98 | int bootloader_type; |
105 | 99 | ||
@@ -476,68 +470,6 @@ unsigned long __init find_max_low_pfn(void) | |||
476 | } | 470 | } |
477 | 471 | ||
478 | /* | 472 | /* |
479 | * Free all available memory for boot time allocation. Used | ||
480 | * as a callback function by efi_memory_walk() | ||
481 | */ | ||
482 | |||
483 | static int __init | ||
484 | free_available_memory(unsigned long start, unsigned long end, void *arg) | ||
485 | { | ||
486 | /* check max_low_pfn */ | ||
487 | if (start >= (max_low_pfn << PAGE_SHIFT)) | ||
488 | return 0; | ||
489 | if (end >= (max_low_pfn << PAGE_SHIFT)) | ||
490 | end = max_low_pfn << PAGE_SHIFT; | ||
491 | if (start < end) | ||
492 | free_bootmem(start, end - start); | ||
493 | |||
494 | return 0; | ||
495 | } | ||
496 | /* | ||
497 | * Register fully available low RAM pages with the bootmem allocator. | ||
498 | */ | ||
499 | static void __init register_bootmem_low_pages(unsigned long max_low_pfn) | ||
500 | { | ||
501 | int i; | ||
502 | |||
503 | if (efi_enabled) { | ||
504 | efi_memmap_walk(free_available_memory, NULL); | ||
505 | return; | ||
506 | } | ||
507 | for (i = 0; i < e820.nr_map; i++) { | ||
508 | unsigned long curr_pfn, last_pfn, size; | ||
509 | /* | ||
510 | * Reserve usable low memory | ||
511 | */ | ||
512 | if (e820.map[i].type != E820_RAM) | ||
513 | continue; | ||
514 | /* | ||
515 | * We are rounding up the start address of usable memory: | ||
516 | */ | ||
517 | curr_pfn = PFN_UP(e820.map[i].addr); | ||
518 | if (curr_pfn >= max_low_pfn) | ||
519 | continue; | ||
520 | /* | ||
521 | * ... and at the end of the usable range downwards: | ||
522 | */ | ||
523 | last_pfn = PFN_DOWN(e820.map[i].addr + e820.map[i].size); | ||
524 | |||
525 | if (last_pfn > max_low_pfn) | ||
526 | last_pfn = max_low_pfn; | ||
527 | |||
528 | /* | ||
529 | * .. finally, did all the rounding and playing | ||
530 | * around just make the area go away? | ||
531 | */ | ||
532 | if (last_pfn <= curr_pfn) | ||
533 | continue; | ||
534 | |||
535 | size = last_pfn - curr_pfn; | ||
536 | free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size)); | ||
537 | } | ||
538 | } | ||
539 | |||
540 | /* | ||
541 | * workaround for Dell systems that neglect to reserve EBDA | 473 | * workaround for Dell systems that neglect to reserve EBDA |
542 | */ | 474 | */ |
543 | static void __init reserve_ebda_region(void) | 475 | static void __init reserve_ebda_region(void) |
@@ -705,56 +637,6 @@ void __init remapped_pgdat_init(void) | |||
705 | } | 637 | } |
706 | } | 638 | } |
707 | 639 | ||
708 | |||
709 | |||
710 | static void __init register_memory(void) | ||
711 | { | ||
712 | unsigned long gapstart, gapsize, round; | ||
713 | unsigned long long last; | ||
714 | int i; | ||
715 | |||
716 | /* | ||
717 | * Search for the bigest gap in the low 32 bits of the e820 | ||
718 | * memory space. | ||
719 | */ | ||
720 | last = 0x100000000ull; | ||
721 | gapstart = 0x10000000; | ||
722 | gapsize = 0x400000; | ||
723 | i = e820.nr_map; | ||
724 | while (--i >= 0) { | ||
725 | unsigned long long start = e820.map[i].addr; | ||
726 | unsigned long long end = start + e820.map[i].size; | ||
727 | |||
728 | /* | ||
729 | * Since "last" is at most 4GB, we know we'll | ||
730 | * fit in 32 bits if this condition is true | ||
731 | */ | ||
732 | if (last > end) { | ||
733 | unsigned long gap = last - end; | ||
734 | |||
735 | if (gap > gapsize) { | ||
736 | gapsize = gap; | ||
737 | gapstart = end; | ||
738 | } | ||
739 | } | ||
740 | if (start < last) | ||
741 | last = start; | ||
742 | } | ||
743 | |||
744 | /* | ||
745 | * See how much we want to round up: start off with | ||
746 | * rounding to the next 1MB area. | ||
747 | */ | ||
748 | round = 0x100000; | ||
749 | while ((gapsize >> 4) > round) | ||
750 | round += round; | ||
751 | /* Fun with two's complement */ | ||
752 | pci_mem_start = (gapstart + round) & -round; | ||
753 | |||
754 | printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n", | ||
755 | pci_mem_start, gapstart, gapsize); | ||
756 | } | ||
757 | |||
758 | #ifdef CONFIG_MCA | 640 | #ifdef CONFIG_MCA |
759 | static void set_mca_bus(int x) | 641 | static void set_mca_bus(int x) |
760 | { | 642 | { |