diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-06-16 22:58:28 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-08 04:38:25 -0400 |
commit | 064d25f12014ae1d97c2882f9ab874995321f2b2 (patch) | |
tree | a6f39b226bbae5a2abc15d911cdf12d01b9c8c19 /arch | |
parent | cc9f7a0ccf000d4db5fbdc7b0ae48eefea102f69 (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')
-rw-r--r-- | arch/x86/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/x86/kernel/e820.c | 72 | ||||
-rw-r--r-- | arch/x86/kernel/e820_32.c | 29 | ||||
-rw-r--r-- | arch/x86/kernel/e820_64.c | 92 | ||||
-rw-r--r-- | arch/x86/kernel/setup_64.c | 8 | ||||
-rw-r--r-- | arch/x86/mach-default/setup.c | 47 | ||||
-rw-r--r-- | arch/x86/mm/init_64.c | 12 |
7 files changed, 86 insertions, 176 deletions
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index dc3c636d113e..bcc2b123dabf 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile | |||
@@ -22,7 +22,7 @@ obj-y += setup_$(BITS).o i8259_$(BITS).o setup.o | |||
22 | obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o | 22 | obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o |
23 | obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o | 23 | obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o |
24 | obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o setup64.o | 24 | obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o setup64.o |
25 | obj-y += bootflag.o e820_$(BITS).o e820.o | 25 | obj-y += bootflag.o e820.o |
26 | obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o | 26 | obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o |
27 | obj-y += alternative.o i8253.o pci-nommu.o | 27 | obj-y += alternative.o i8253.o pci-nommu.o |
28 | obj-$(CONFIG_X86_64) += bugs_64.o | 28 | obj-$(CONFIG_X86_64) += bugs_64.o |
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 | ||
1032 | char *__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 */ | ||
1074 | char * __init __attribute__((weak)) memory_setup(void) | ||
1075 | { | ||
1076 | return machine_specific_memory_setup(); | ||
1077 | } | ||
1078 | |||
1079 | void __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 | ||
1086 | int __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 | ||
diff --git a/arch/x86/kernel/e820_32.c b/arch/x86/kernel/e820_32.c deleted file mode 100644 index 1205ccf086d7..000000000000 --- a/arch/x86/kernel/e820_32.c +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/types.h> | ||
3 | #include <linux/init.h> | ||
4 | #include <linux/bootmem.h> | ||
5 | #include <linux/ioport.h> | ||
6 | #include <linux/string.h> | ||
7 | #include <linux/kexec.h> | ||
8 | #include <linux/module.h> | ||
9 | #include <linux/mm.h> | ||
10 | #include <linux/pfn.h> | ||
11 | #include <linux/uaccess.h> | ||
12 | |||
13 | #include <asm/pgtable.h> | ||
14 | #include <asm/page.h> | ||
15 | #include <asm/e820.h> | ||
16 | #include <asm/setup.h> | ||
17 | |||
18 | /* Overridden in paravirt.c if CONFIG_PARAVIRT */ | ||
19 | char * __init __attribute__((weak)) memory_setup(void) | ||
20 | { | ||
21 | return machine_specific_memory_setup(); | ||
22 | } | ||
23 | |||
24 | void __init setup_memory_map(void) | ||
25 | { | ||
26 | printk(KERN_INFO "BIOS-provided physical RAM map:\n"); | ||
27 | e820_print_map(memory_setup()); | ||
28 | } | ||
29 | |||
diff --git a/arch/x86/kernel/e820_64.c b/arch/x86/kernel/e820_64.c deleted file mode 100644 index cb03bff9fa2f..000000000000 --- a/arch/x86/kernel/e820_64.c +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | /* | ||
2 | * Handle the memory map. | ||
3 | * The functions here do the job until bootmem takes over. | ||
4 | * | ||
5 | * Getting sanitize_e820_map() in sync with i386 version by applying change: | ||
6 | * - Provisions for empty E820 memory regions (reported by certain BIOSes). | ||
7 | * Alex Achenbach <xela@slit.de>, December 2002. | ||
8 | * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | ||
9 | * | ||
10 | */ | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/types.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/bootmem.h> | ||
15 | #include <linux/ioport.h> | ||
16 | #include <linux/string.h> | ||
17 | #include <linux/kexec.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/mm.h> | ||
20 | #include <linux/pfn.h> | ||
21 | #include <linux/pci.h> | ||
22 | |||
23 | #include <asm/pgtable.h> | ||
24 | #include <asm/page.h> | ||
25 | #include <asm/e820.h> | ||
26 | #include <asm/proto.h> | ||
27 | #include <asm/setup.h> | ||
28 | #include <asm/sections.h> | ||
29 | #include <asm/kdebug.h> | ||
30 | #include <asm/trampoline.h> | ||
31 | |||
32 | /* | ||
33 | * PFN of last memory page. | ||
34 | */ | ||
35 | unsigned long end_pfn; | ||
36 | |||
37 | /* | ||
38 | * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries. | ||
39 | * The direct mapping extends to max_pfn_mapped, so that we can directly access | ||
40 | * apertures, ACPI and other tables without having to play with fixmaps. | ||
41 | */ | ||
42 | unsigned long max_pfn_mapped; | ||
43 | |||
44 | static void early_panic(char *msg) | ||
45 | { | ||
46 | early_printk(msg); | ||
47 | panic(msg); | ||
48 | } | ||
49 | |||
50 | /* We're not void only for x86 32-bit compat */ | ||
51 | char *__init machine_specific_memory_setup(void) | ||
52 | { | ||
53 | char *who = "BIOS-e820"; | ||
54 | int new_nr; | ||
55 | /* | ||
56 | * Try to copy the BIOS-supplied E820-map. | ||
57 | * | ||
58 | * Otherwise fake a memory map; one section from 0k->640k, | ||
59 | * the next section from 1mb->appropriate_mem_k | ||
60 | */ | ||
61 | new_nr = boot_params.e820_entries; | ||
62 | sanitize_e820_map(boot_params.e820_map, | ||
63 | ARRAY_SIZE(boot_params.e820_map), | ||
64 | &new_nr); | ||
65 | boot_params.e820_entries = new_nr; | ||
66 | if (copy_e820_map(boot_params.e820_map, boot_params.e820_entries) < 0) | ||
67 | early_panic("Cannot find a valid memory map"); | ||
68 | printk(KERN_INFO "BIOS-provided physical RAM map:\n"); | ||
69 | e820_print_map(who); | ||
70 | |||
71 | /* In case someone cares... */ | ||
72 | return who; | ||
73 | } | ||
74 | |||
75 | int __init arch_get_ram_range(int slot, u64 *addr, u64 *size) | ||
76 | { | ||
77 | int i; | ||
78 | |||
79 | if (slot < 0 || slot >= e820.nr_map) | ||
80 | return -1; | ||
81 | for (i = slot; i < e820.nr_map; i++) { | ||
82 | if (e820.map[i].type != E820_RAM) | ||
83 | continue; | ||
84 | break; | ||
85 | } | ||
86 | if (i == e820.nr_map || e820.map[i].addr > (max_pfn << PAGE_SHIFT)) | ||
87 | return -1; | ||
88 | *addr = e820.map[i].addr; | ||
89 | *size = min_t(u64, e820.map[i].size + e820.map[i].addr, | ||
90 | max_pfn << PAGE_SHIFT) - *addr; | ||
91 | return i + 1; | ||
92 | } | ||
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c index ec65696ca2cd..3220c7b56eb3 100644 --- a/arch/x86/kernel/setup_64.c +++ b/arch/x86/kernel/setup_64.c | |||
@@ -266,12 +266,6 @@ static inline void __init reserve_crashkernel(void) | |||
266 | {} | 266 | {} |
267 | #endif | 267 | #endif |
268 | 268 | ||
269 | /* Overridden in paravirt.c if CONFIG_PARAVIRT */ | ||
270 | void __attribute__((weak)) __init memory_setup(void) | ||
271 | { | ||
272 | machine_specific_memory_setup(); | ||
273 | } | ||
274 | |||
275 | #ifdef CONFIG_PCI_MMCONFIG | 269 | #ifdef CONFIG_PCI_MMCONFIG |
276 | extern void __cpuinit fam10h_check_enable_mmcfg(void); | 270 | extern void __cpuinit fam10h_check_enable_mmcfg(void); |
277 | extern void __init check_enable_amd_mmconf_dmi(void); | 271 | extern void __init check_enable_amd_mmconf_dmi(void); |
@@ -316,7 +310,7 @@ void __init setup_arch(char **cmdline_p) | |||
316 | 310 | ||
317 | ARCH_SETUP | 311 | ARCH_SETUP |
318 | 312 | ||
319 | memory_setup(); | 313 | setup_memory_map(); |
320 | copy_edd(); | 314 | copy_edd(); |
321 | 315 | ||
322 | if (!boot_params.hdr.root_flags) | 316 | if (!boot_params.hdr.root_flags) |
diff --git a/arch/x86/mach-default/setup.c b/arch/x86/mach-default/setup.c index 7ae692a76769..2f5e277686b8 100644 --- a/arch/x86/mach-default/setup.c +++ b/arch/x86/mach-default/setup.c | |||
@@ -142,50 +142,3 @@ static int __init print_ipi_mode(void) | |||
142 | 142 | ||
143 | late_initcall(print_ipi_mode); | 143 | late_initcall(print_ipi_mode); |
144 | 144 | ||
145 | /** | ||
146 | * machine_specific_memory_setup - Hook for machine specific memory setup. | ||
147 | * | ||
148 | * Description: | ||
149 | * This is included late in kernel/setup.c so that it can make | ||
150 | * use of all of the static functions. | ||
151 | **/ | ||
152 | |||
153 | char * __init machine_specific_memory_setup(void) | ||
154 | { | ||
155 | char *who; | ||
156 | int new_nr; | ||
157 | |||
158 | |||
159 | who = "BIOS-e820"; | ||
160 | |||
161 | /* | ||
162 | * Try to copy the BIOS-supplied E820-map. | ||
163 | * | ||
164 | * Otherwise fake a memory map; one section from 0k->640k, | ||
165 | * the next section from 1mb->appropriate_mem_k | ||
166 | */ | ||
167 | new_nr = boot_params.e820_entries; | ||
168 | sanitize_e820_map(boot_params.e820_map, | ||
169 | ARRAY_SIZE(boot_params.e820_map), | ||
170 | &new_nr); | ||
171 | boot_params.e820_entries = new_nr; | ||
172 | if (copy_e820_map(boot_params.e820_map, boot_params.e820_entries) | ||
173 | < 0) { | ||
174 | unsigned long mem_size; | ||
175 | |||
176 | /* compare results from other methods and take the greater */ | ||
177 | if (boot_params.alt_mem_k | ||
178 | < boot_params.screen_info.ext_mem_k) { | ||
179 | mem_size = boot_params.screen_info.ext_mem_k; | ||
180 | who = "BIOS-88"; | ||
181 | } else { | ||
182 | mem_size = boot_params.alt_mem_k; | ||
183 | who = "BIOS-e801"; | ||
184 | } | ||
185 | |||
186 | e820.nr_map = 0; | ||
187 | e820_add_region(0, LOWMEMSIZE(), E820_RAM); | ||
188 | e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM); | ||
189 | } | ||
190 | return who; | ||
191 | } | ||
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index b8c2c1ef7ad5..5266f3141d6c 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c | |||
@@ -47,6 +47,18 @@ | |||
47 | #include <asm/numa.h> | 47 | #include <asm/numa.h> |
48 | #include <asm/cacheflush.h> | 48 | #include <asm/cacheflush.h> |
49 | 49 | ||
50 | /* | ||
51 | * PFN of last memory page. | ||
52 | */ | ||
53 | unsigned long end_pfn; | ||
54 | |||
55 | /* | ||
56 | * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries. | ||
57 | * The direct mapping extends to max_pfn_mapped, so that we can directly access | ||
58 | * apertures, ACPI and other tables without having to play with fixmaps. | ||
59 | */ | ||
60 | unsigned long max_pfn_mapped; | ||
61 | |||
50 | static unsigned long dma_reserve __initdata; | 62 | static unsigned long dma_reserve __initdata; |
51 | 63 | ||
52 | DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); | 64 | DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); |