diff options
author | Magnus Damm <damm@igel.co.jp> | 2008-08-27 17:32:26 +1000 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2008-08-27 17:32:26 +1000 |
commit | 4c3af19e8a98a11effa56fe21d3f557e15017f02 (patch) | |
tree | c84fe2eb081c4d1c054383dbf7b8aaa4571a4620 | |
parent | 4b10f34bdc404f2c174fcb9b6a8638cb2ee96765 (diff) |
sh: Get system memory ranges from /proc/iomem
Parse contents of /proc/iomem instead of hardcoding RAM ranges.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | kexec/arch/sh/kexec-sh.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/kexec/arch/sh/kexec-sh.c b/kexec/arch/sh/kexec-sh.c index d75f339..ebac77f 100644 --- a/kexec/arch/sh/kexec-sh.c +++ b/kexec/arch/sh/kexec-sh.c @@ -22,19 +22,31 @@ #define MAX_MEMORY_RANGES 64 static struct memory_range memory_range[MAX_MEMORY_RANGES]; +static int kexec_sh_memory_range_callback(void *data, int nr, + char *str, + unsigned long base, + unsigned long length) +{ + if (nr < MAX_MEMORY_RANGES) { + memory_range[nr].start = base; + memory_range[nr].end = base + length - 1; + memory_range[nr].type = RANGE_RAM; + return 0; + } + + return 1; +} + /* Return a sorted list of available memory ranges. */ int get_memory_ranges(struct memory_range **range, int *ranges, unsigned long kexec_flags) { - int memory_ranges; + int nr; - memory_ranges = 0; - memory_range[memory_ranges].start = 0x08000000; - memory_range[memory_ranges].end = 0x10000000; - memory_range[memory_ranges].type = RANGE_RAM; - memory_ranges++; + nr = kexec_iomem_for_each_line("System RAM\n", + kexec_sh_memory_range_callback, NULL); *range = memory_range; - *ranges = memory_ranges; + *ranges = nr; return 0; } |