diff options
author | Yinghai Lu <yinghai@kernel.org> | 2010-08-25 16:39:15 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-08-27 14:08:21 -0400 |
commit | 27de794365786b4cdc3461ed4e23af2a33f40612 (patch) | |
tree | 7aa2ab1a7f21ed2f91647f8a73ed2e0ebf45048f /arch | |
parent | f88eff74aa848e58b1ea49768c0bbb874b31357f (diff) |
x86, memblock: Add memblock_x86_to_bootmem()
memblock_x86_to_bootmem() will reserve memblock.reserved.region in
bootmem after bootmem is set up.
We can use it to with all arches that support memblock later.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/memblock.h | 1 | ||||
-rw-r--r-- | arch/x86/mm/memblock.c | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h index c14219a26168..69cf853e9319 100644 --- a/arch/x86/include/asm/memblock.h +++ b/arch/x86/include/asm/memblock.h | |||
@@ -4,5 +4,6 @@ | |||
4 | #define ARCH_DISCARD_MEMBLOCK | 4 | #define ARCH_DISCARD_MEMBLOCK |
5 | 5 | ||
6 | u64 memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align); | 6 | u64 memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align); |
7 | void memblock_x86_to_bootmem(u64 start, u64 end); | ||
7 | 8 | ||
8 | #endif | 9 | #endif |
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index 26ba46234cba..8101084d452a 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c | |||
@@ -85,3 +85,32 @@ u64 __init memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align) | |||
85 | 85 | ||
86 | return MEMBLOCK_ERROR; | 86 | return MEMBLOCK_ERROR; |
87 | } | 87 | } |
88 | |||
89 | #ifndef CONFIG_NO_BOOTMEM | ||
90 | void __init memblock_x86_to_bootmem(u64 start, u64 end) | ||
91 | { | ||
92 | int count; | ||
93 | u64 final_start, final_end; | ||
94 | struct memblock_region *r; | ||
95 | |||
96 | /* Take out region array itself */ | ||
97 | memblock_free_reserved_regions(); | ||
98 | |||
99 | count = memblock.reserved.cnt; | ||
100 | pr_info("(%d early reservations) ==> bootmem [%010llx-%010llx]\n", count, start, end - 1); | ||
101 | for_each_memblock(reserved, r) { | ||
102 | pr_info(" [%010llx-%010llx] ", (u64)r->base, (u64)r->base + r->size - 1); | ||
103 | final_start = max(start, r->base); | ||
104 | final_end = min(end, r->base + r->size); | ||
105 | if (final_start >= final_end) { | ||
106 | pr_cont("\n"); | ||
107 | continue; | ||
108 | } | ||
109 | pr_cont(" ==> [%010llx-%010llx]\n", final_start, final_end - 1); | ||
110 | reserve_bootmem_generic(final_start, final_end - final_start, BOOTMEM_DEFAULT); | ||
111 | } | ||
112 | |||
113 | /* Put region array back ? */ | ||
114 | memblock_reserve_reserved_regions(); | ||
115 | } | ||
116 | #endif | ||