aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2010-02-16 21:40:35 -0500
committerH. Peter Anvin <hpa@zytor.com>2010-02-17 00:43:39 -0500
commit580e0ad21d6d6f932461d24b47041e3dd499c23f (patch)
tree3476c71849c0f9aa54c160b9a994bf4d211bd697
parentdd645cee7b50b61cb2d05b59eb6027679c437af6 (diff)
core: Move early_res from arch/x86 to kernel/
This makes the range reservation feature available to other architectures. -v2: add get_max_mapped, max_pfn_mapped only defined in x86... to fix PPC compiling -v3: according to hpa, add CONFIG_HAVE_EARLY_RES -v4: fix typo about EARLY_RES in config Signed-off-by: Yinghai Lu <yinghai@kernel.org> LKML-Reference: <4B7B5723.4070009@kernel.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--arch/x86/Kconfig3
-rw-r--r--arch/x86/include/asm/e820.h2
-rw-r--r--arch/x86/kernel/Makefile2
-rw-r--r--arch/x86/kernel/e820.c10
-rw-r--r--include/linux/early_res.h (renamed from arch/x86/include/asm/early_res.h)7
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/early_res.c (renamed from arch/x86/kernel/early_res.c)16
7 files changed, 23 insertions, 18 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 29f9efb74fc7..0e9f8b10de52 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -183,6 +183,9 @@ config ARCH_SUPPORTS_OPTIMIZED_INLINING
183config ARCH_SUPPORTS_DEBUG_PAGEALLOC 183config ARCH_SUPPORTS_DEBUG_PAGEALLOC
184 def_bool y 184 def_bool y
185 185
186config HAVE_EARLY_RES
187 def_bool y
188
186config HAVE_INTEL_TXT 189config HAVE_INTEL_TXT
187 def_bool y 190 def_bool y
188 depends on EXPERIMENTAL && DMAR && ACPI 191 depends on EXPERIMENTAL && DMAR && ACPI
diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
index a8299e134437..0e22296790d3 100644
--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -112,7 +112,7 @@ extern unsigned long end_user_pfn;
112extern u64 find_e820_area(u64 start, u64 end, u64 size, u64 align); 112extern u64 find_e820_area(u64 start, u64 end, u64 size, u64 align);
113extern u64 find_e820_area_size(u64 start, u64 *sizep, u64 align); 113extern u64 find_e820_area_size(u64 start, u64 *sizep, u64 align);
114extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); 114extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align);
115#include <asm/early_res.h> 115#include <linux/early_res.h>
116 116
117extern unsigned long e820_end_of_ram_pfn(void); 117extern unsigned long e820_end_of_ram_pfn(void);
118extern unsigned long e820_end_of_low_ram_pfn(void); 118extern unsigned long e820_end_of_low_ram_pfn(void);
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index f5fb9f0b6277..d87f09bc5a52 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -38,7 +38,7 @@ obj-$(CONFIG_X86_32) += probe_roms_32.o
38obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o 38obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
39obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o 39obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
40obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o 40obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o
41obj-y += bootflag.o e820.o early_res.o 41obj-y += bootflag.o e820.o
42obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o 42obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o
43obj-y += alternative.o i8253.o pci-nommu.o hw_breakpoint.o 43obj-y += alternative.o i8253.o pci-nommu.o hw_breakpoint.o
44obj-y += tsc.o io_delay.o rtc.o 44obj-y += tsc.o io_delay.o rtc.o
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 36918d8463ab..740b440fbd73 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -17,7 +17,6 @@
17#include <linux/firmware-map.h> 17#include <linux/firmware-map.h>
18 18
19#include <asm/e820.h> 19#include <asm/e820.h>
20#include <asm/early_res.h>
21#include <asm/proto.h> 20#include <asm/proto.h>
22#include <asm/setup.h> 21#include <asm/setup.h>
23 22
@@ -752,6 +751,15 @@ u64 __init find_fw_memmap_area(u64 start, u64 end, u64 size, u64 align)
752{ 751{
753 return find_e820_area(start, end, size, align); 752 return find_e820_area(start, end, size, align);
754} 753}
754
755u64 __init get_max_mapped(void)
756{
757 u64 end = max_pfn_mapped;
758
759 end <<= PAGE_SHIFT;
760
761 return end;
762}
755/* 763/*
756 * Find next free range after *start 764 * Find next free range after *start
757 */ 765 */
diff --git a/arch/x86/include/asm/early_res.h b/include/linux/early_res.h
index 9758f3df9dad..50f7663bb8b1 100644
--- a/arch/x86/include/asm/early_res.h
+++ b/include/linux/early_res.h
@@ -1,5 +1,5 @@
1#ifndef _ASM_X86_EARLY_RES_H 1#ifndef _LINUX_EARLY_RES_H
2#define _ASM_X86_EARLY_RES_H 2#define _LINUX_EARLY_RES_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5extern void reserve_early(u64 start, u64 end, char *name); 5extern void reserve_early(u64 start, u64 end, char *name);
@@ -13,9 +13,10 @@ u64 find_early_area(u64 ei_start, u64 ei_last, u64 start, u64 end,
13u64 find_early_area_size(u64 ei_start, u64 ei_last, u64 start, 13u64 find_early_area_size(u64 ei_start, u64 ei_last, u64 start,
14 u64 *sizep, u64 align); 14 u64 *sizep, u64 align);
15u64 find_fw_memmap_area(u64 start, u64 end, u64 size, u64 align); 15u64 find_fw_memmap_area(u64 start, u64 end, u64 size, u64 align);
16u64 get_max_mapped(void);
16#include <linux/range.h> 17#include <linux/range.h>
17int get_free_all_memory_range(struct range **rangep, int nodeid); 18int get_free_all_memory_range(struct range **rangep, int nodeid);
18 19
19#endif /* __KERNEL__ */ 20#endif /* __KERNEL__ */
20 21
21#endif /* _ASM_X86_EARLY_RES_H */ 22#endif /* _LINUX_EARLY_RES_H */
diff --git a/kernel/Makefile b/kernel/Makefile
index ad47330ccf32..1292b863d667 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -11,6 +11,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \
11 hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ 11 hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
12 notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \ 12 notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \
13 async.o range.o 13 async.o range.o
14obj-$(CONFIG_HAVE_EARLY_RES) += early_res.o
14obj-y += groups.o 15obj-y += groups.o
15 16
16ifdef CONFIG_FUNCTION_TRACER 17ifdef CONFIG_FUNCTION_TRACER
diff --git a/arch/x86/kernel/early_res.c b/kernel/early_res.c
index 1458dc022343..aa5494ac4462 100644
--- a/arch/x86/kernel/early_res.c
+++ b/kernel/early_res.c
@@ -6,8 +6,7 @@
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/bootmem.h> 7#include <linux/bootmem.h>
8#include <linux/mm.h> 8#include <linux/mm.h>
9 9#include <linux/early_res.h>
10#include <asm/early_res.h>
11 10
12/* 11/*
13 * Early reserved memory areas. 12 * Early reserved memory areas.
@@ -178,13 +177,6 @@ void __init reserve_early_overlap_ok(u64 start, u64 end, char *name)
178 __reserve_early(start, end, name, 1); 177 __reserve_early(start, end, name, 1);
179} 178}
180 179
181u64 __init __weak find_fw_memmap_area(u64 start, u64 end, u64 size, u64 align)
182{
183 panic("should have find_fw_memmap_area defined with arch");
184
185 return -1ULL;
186}
187
188static void __init __check_and_double_early_res(u64 ex_start, u64 ex_end) 180static void __init __check_and_double_early_res(u64 ex_start, u64 ex_end)
189{ 181{
190 u64 start, end, size, mem; 182 u64 start, end, size, mem;
@@ -207,7 +199,7 @@ static void __init __check_and_double_early_res(u64 ex_start, u64 ex_end)
207 sizeof(struct early_res)); 199 sizeof(struct early_res));
208 if (mem == -1ULL) { 200 if (mem == -1ULL) {
209 start = ex_end; 201 start = ex_end;
210 end = max_pfn_mapped << PAGE_SHIFT; 202 end = get_max_mapped();
211 if (start + size < end) 203 if (start + size < end)
212 mem = find_fw_memmap_area(start, end, size, 204 mem = find_fw_memmap_area(start, end, size,
213 sizeof(struct early_res)); 205 sizeof(struct early_res));
@@ -343,11 +335,11 @@ int __init get_free_all_memory_range(struct range **rangep, int nodeid)
343 count *= 2; 335 count *= 2;
344 336
345 size = sizeof(struct range) * count; 337 size = sizeof(struct range) * count;
338 end = get_max_mapped();
346#ifdef MAX_DMA32_PFN 339#ifdef MAX_DMA32_PFN
347 if (max_pfn_mapped > MAX_DMA32_PFN) 340 if (end > (MAX_DMA32_PFN << PAGE_SHIFT))
348 start = MAX_DMA32_PFN << PAGE_SHIFT; 341 start = MAX_DMA32_PFN << PAGE_SHIFT;
349#endif 342#endif
350 end = max_pfn_mapped << PAGE_SHIFT;
351 mem = find_fw_memmap_area(start, end, size, sizeof(struct range)); 343 mem = find_fw_memmap_area(start, end, size, sizeof(struct range));
352 if (mem == -1ULL) 344 if (mem == -1ULL)
353 panic("can not find more space for range free"); 345 panic("can not find more space for range free");