aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/e820.c
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-06-16 22:58:28 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-08 04:38:25 -0400
commit064d25f12014ae1d97c2882f9ab874995321f2b2 (patch)
treea6f39b226bbae5a2abc15d911cdf12d01b9c8c19 /arch/x86/kernel/e820.c
parentcc9f7a0ccf000d4db5fbdc7b0ae48eefea102f69 (diff)
x86: merge setup_memory_map with e820
... and kill e820_32/64.c and e820_32/64.h Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/e820.c')
-rw-r--r--arch/x86/kernel/e820.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 432c49178577..49477484a2fa 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1029,4 +1029,76 @@ void __init e820_reserve_resources(void)
1029 } 1029 }
1030} 1030}
1031 1031
1032char *__init __attribute__((weak)) machine_specific_memory_setup(void)
1033{
1034 char *who = "BIOS-e820";
1035 int new_nr;
1036 /*
1037 * Try to copy the BIOS-supplied E820-map.
1038 *
1039 * Otherwise fake a memory map; one section from 0k->640k,
1040 * the next section from 1mb->appropriate_mem_k
1041 */
1042 new_nr = boot_params.e820_entries;
1043 sanitize_e820_map(boot_params.e820_map,
1044 ARRAY_SIZE(boot_params.e820_map),
1045 &new_nr);
1046 boot_params.e820_entries = new_nr;
1047 if (copy_e820_map(boot_params.e820_map, boot_params.e820_entries) < 0) {
1048#ifdef CONFIG_X86_64
1049 early_panic("Cannot find a valid memory map");
1050#else
1051 unsigned long mem_size;
1052
1053 /* compare results from other methods and take the greater */
1054 if (boot_params.alt_mem_k
1055 < boot_params.screen_info.ext_mem_k) {
1056 mem_size = boot_params.screen_info.ext_mem_k;
1057 who = "BIOS-88";
1058 } else {
1059 mem_size = boot_params.alt_mem_k;
1060 who = "BIOS-e801";
1061 }
1062
1063 e820.nr_map = 0;
1064 e820_add_region(0, LOWMEMSIZE(), E820_RAM);
1065 e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
1066#endif
1067 }
1068
1069 /* In case someone cares... */
1070 return who;
1071}
1072
1073/* Overridden in paravirt.c if CONFIG_PARAVIRT */
1074char * __init __attribute__((weak)) memory_setup(void)
1075{
1076 return machine_specific_memory_setup();
1077}
1078
1079void __init setup_memory_map(void)
1080{
1081 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
1082 e820_print_map(memory_setup());
1083}
1084
1085#ifdef CONFIG_X86_64
1086int __init arch_get_ram_range(int slot, u64 *addr, u64 *size)
1087{
1088 int i;
1032 1089
1090 if (slot < 0 || slot >= e820.nr_map)
1091 return -1;
1092 for (i = slot; i < e820.nr_map; i++) {
1093 if (e820.map[i].type != E820_RAM)
1094 continue;
1095 break;
1096 }
1097 if (i == e820.nr_map || e820.map[i].addr > (max_pfn << PAGE_SHIFT))
1098 return -1;
1099 *addr = e820.map[i].addr;
1100 *size = min_t(u64, e820.map[i].size + e820.map[i].addr,
1101 max_pfn << PAGE_SHIFT) - *addr;
1102 return i + 1;
1103}
1104#endif