diff options
author | Daniel Kiper <daniel.kiper@oracle.com> | 2012-09-10 13:57:48 +0200 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2012-09-18 10:09:45 +0900 |
commit | c02245b2453f27c49dd080dd9d64a36bed9ec446 (patch) | |
tree | c13b09dd05b84c80e184135f9f9c180ab50f442e | |
parent | 0141ec77f2e2c08e720777a1c4879ccec5c069a6 (diff) | |
download | kexec-tools-c02245b2453f27c49dd080dd9d64a36bed9ec446.tar.gz |
kexec: Add segregate_lowmem_region()
Extract code segregating lowmem region and move it to new
segregate_lowmem_region(). This function will be used by
fixed Xen kdump support, too.
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | kexec/arch/i386/crashdump-x86.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c index ec9432bc..77a1329b 100644 --- a/kexec/arch/i386/crashdump-x86.c +++ b/kexec/arch/i386/crashdump-x86.c @@ -159,6 +159,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info), } /* Forward Declaration. */ +static void segregate_lowmem_region(int *nr_ranges, unsigned long lowmem_limit); static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end); /* Stores a sorted list of RAM memory ranges for which to create elf headers. @@ -235,19 +236,10 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, crash_memory_range[memory_ranges].start = start; crash_memory_range[memory_ranges].end = end; crash_memory_range[memory_ranges].type = type; - memory_ranges++; - /* Segregate linearly mapped region. */ - if (lowmem_limit && - (lowmem_limit - 1) >= start && (lowmem_limit - 1) <= end) { - crash_memory_range[memory_ranges-1].end = lowmem_limit -1; + segregate_lowmem_region(&memory_ranges, lowmem_limit); - /* Add segregated region. */ - crash_memory_range[memory_ranges].start = lowmem_limit; - crash_memory_range[memory_ranges].end = end; - crash_memory_range[memory_ranges].type = type; - memory_ranges++; - } + memory_ranges++; } fclose(fp); if (kexec_flags & KEXEC_PRESERVE_CONTEXT) { @@ -289,6 +281,30 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, return 0; } +static void segregate_lowmem_region(int *nr_ranges, unsigned long lowmem_limit) +{ + unsigned long long end, start; + unsigned type; + + start = crash_memory_range[*nr_ranges].start; + end = crash_memory_range[*nr_ranges].end; + type = crash_memory_range[*nr_ranges].type; + + if (!(lowmem_limit && lowmem_limit > start && lowmem_limit < end)) + return; + + crash_memory_range[*nr_ranges].end = lowmem_limit - 1; + + if (*nr_ranges >= CRASH_MAX_MEMORY_RANGES - 1) + return; + + ++*nr_ranges; + + crash_memory_range[*nr_ranges].start = lowmem_limit; + crash_memory_range[*nr_ranges].end = end; + crash_memory_range[*nr_ranges].type = type; +} + /* Removes crash reserve region from list of memory chunks for whom elf program * headers have to be created. Assuming crash reserve region to be a single * continuous area fully contained inside one of the memory chunks */ |