From fd6493e16625b92a506fba13deda31c0be5f1cd4 Mon Sep 17 00:00:00 2001 From: Alok Kataria Date: Wed, 25 Jun 2008 11:02:42 -0700 Subject: x86: cleanup e820_setup_gap(), v2 e820_search_gap also take a end_addr parameter to limit search from start_addr to end_addr. Signed-off-by: AloK N Kataria Acked-by: Yinghai Lu Cc: "lenb@kernel.org" Signed-off-by: Ingo Molnar --- arch/x86/kernel/e820.c | 12 +++++++----- include/asm-x86/e820.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index e03b89ac8f2..d3f6c5f6d3b 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -487,17 +487,19 @@ void __init update_e820(void) printk(KERN_INFO "modified physical RAM map:\n"); e820_print_map("modified"); } - +#define MAX_GAP_END 0x100000000ull /* - * Search for a gap in the e820 memory space from start_addr to 2^32. + * Search for a gap in the e820 memory space from start_addr to end_addr. */ __init int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize, - unsigned long start_addr) + unsigned long start_addr, unsigned long long end_addr) { - unsigned long long last = 0x100000000ull; + unsigned long long last; int i = e820.nr_map; int found = 0; + last = (end_addr && end_addr < MAX_GAP_END) ? end_addr : MAX_GAP_END; + while (--i >= 0) { unsigned long long start = e820.map[i].addr; unsigned long long end = start + e820.map[i].size; @@ -537,7 +539,7 @@ __init void e820_setup_gap(void) gapstart = 0x10000000; gapsize = 0x400000; - found = e820_search_gap(&gapstart, &gapsize, 0); + found = e820_search_gap(&gapstart, &gapsize, 0, MAX_GAP_END); #ifdef CONFIG_X86_64 if (!found) { diff --git a/include/asm-x86/e820.h b/include/asm-x86/e820.h index 45e904fe407..05a7dc33334 100644 --- a/include/asm-x86/e820.h +++ b/include/asm-x86/e820.h @@ -75,7 +75,7 @@ extern u64 e820_remove_range(u64 start, u64 size, unsigned old_type, extern void update_e820(void); extern void e820_setup_gap(void); extern int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize, - unsigned long start_addr); + unsigned long start_addr, unsigned long long end_addr); struct setup_data; extern void parse_e820_ext(struct setup_data *data, unsigned long pa_data); -- cgit v1.2.3