summaryrefslogtreecommitdiffstats
path: root/arch/x86/mm/memblock.c
diff options
context:
space:
mode:
authorYinghai Lu2010-08-25 22:39:15 +0200
committerH. Peter Anvin2010-08-27 20:08:21 +0200
commit27de794365786b4cdc3461ed4e23af2a33f40612 (patch)
tree7aa2ab1a7f21ed2f91647f8a73ed2e0ebf45048f /arch/x86/mm/memblock.c
parentbootmem, x86: Add weak version of reserve_bootmem_generic (diff)
downloadkernel-qcow2-linux-27de794365786b4cdc3461ed4e23af2a33f40612.tar.gz
kernel-qcow2-linux-27de794365786b4cdc3461ed4e23af2a33f40612.tar.xz
kernel-qcow2-linux-27de794365786b4cdc3461ed4e23af2a33f40612.zip
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/x86/mm/memblock.c')
-rw-r--r--arch/x86/mm/memblock.c29
1 files changed, 29 insertions, 0 deletions
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)
return MEMBLOCK_ERROR;
}
+
+#ifndef CONFIG_NO_BOOTMEM
+void __init memblock_x86_to_bootmem(u64 start, u64 end)
+{
+ int count;
+ u64 final_start, final_end;
+ struct memblock_region *r;
+
+ /* Take out region array itself */
+ memblock_free_reserved_regions();
+
+ count = memblock.reserved.cnt;
+ pr_info("(%d early reservations) ==> bootmem [%010llx-%010llx]\n", count, start, end - 1);
+ for_each_memblock(reserved, r) {
+ pr_info(" [%010llx-%010llx] ", (u64)r->base, (u64)r->base + r->size - 1);
+ final_start = max(start, r->base);
+ final_end = min(end, r->base + r->size);
+ if (final_start >= final_end) {
+ pr_cont("\n");
+ continue;
+ }
+ pr_cont(" ==> [%010llx-%010llx]\n", final_start, final_end - 1);
+ reserve_bootmem_generic(final_start, final_end - final_start, BOOTMEM_DEFAULT);
+ }
+
+ /* Put region array back ? */
+ memblock_reserve_reserved_regions();
+}
+#endif