diff options
author | Yinghai Lu <yinghai@kernel.org> | 2010-02-10 01:20:26 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-02-12 09:42:39 -0800 |
commit | efdd0e81df0f23830c6d2cb971cf87f415b8dbdb (patch) | |
tree | 377941fbfeee4cd887ace1de0826a8df03aa965c /arch/x86/kernel/e820.c | |
parent | 7da657d1f1dd27fa9d8289d5f7e53479c7fd3a95 (diff) |
x86: Move back find_e820_area to e820.c
Makes early_res.c more clean, so later could move it to /kernel.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <1265793639-15071-23-git-send-email-yinghai@kernel.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/kernel/e820.c')
-rw-r--r-- | arch/x86/kernel/e820.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 82db4015604..b4e512b03aa 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -723,6 +723,59 @@ core_initcall(e820_mark_nvs_memory); #endif /* + * Find a free area with specified alignment in a specific range. + */ +u64 __init find_e820_area(u64 start, u64 end, u64 size, u64 align) +{ + int i; + + for (i = 0; i < e820.nr_map; i++) { + struct e820entry *ei = &e820.map[i]; + u64 addr; + u64 ei_start, ei_last; + + if (ei->type != E820_RAM) + continue; + + ei_last = ei->addr + ei->size; + ei_start = ei->addr; + addr = find_early_area(ei_start, ei_last, start, end, + size, align); + + if (addr != -1ULL) + return addr; + } + return -1ULL; +} + +/* + * Find next free range after *start + */ +u64 __init find_e820_area_size(u64 start, u64 *sizep, u64 align) +{ + int i; + + for (i = 0; i < e820.nr_map; i++) { + struct e820entry *ei = &e820.map[i]; + u64 addr; + u64 ei_start, ei_last; + + if (ei->type != E820_RAM) + continue; + + ei_last = ei->addr + ei->size; + ei_start = ei->addr; + addr = find_early_area_size(ei_start, ei_last, start, + sizep, align); + + if (addr != -1ULL) + return addr; + } + + return -1ULL; +} + +/* * pre allocated 4k and reserved it in e820 */ u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align) |