Check for crashkernel reservation in i386 and x86-64.
Check whether memory for crashkernel is reserved or not by looking for the
entry "Crash kernel" in /proc/iomem.
Signed-off-by: Mohan Kumar M <[EMAIL PROTECTED]>
---
kexec/arch/i386/kexec-elf-x86.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
index 76ea0e2..d61ce75 100644
--- a/kexec/arch/i386/kexec-elf-x86.c
+++ b/kexec/arch/i386/kexec-elf-x86.c
@@ -83,6 +83,37 @@ void elf_x86_usage(void)
}
+int is_crashkernel_mem_reserved()
+{
+ const char iomem[]= "/proc/iomem";
+ char line[MAX_LINE];
+ FILE *fp;
+ unsigned long long start, end;
+ char *str;
+ int consumed;
+ int count;
+
+ fp = fopen(iomem, "r");
+ if (!fp)
+ die("Cannot open /proc/iomem");
+
+ while(fgets(line, sizeof(line), fp) != 0) {
+ count = sscanf(line, "%Lx-%Lx : %n",
+ &start, &end, &consumed);
+ if (count != 2)
+ continue;
+ str = line + consumed;
+ if (memcmp(str, "Crash kernel\n", 13) == 0)
+ break;
+ }
+
+ fclose(fp);
+ if (!memcmp(str, "Crash kernel\n", 13) == 0 || (start == end))
+ return 0;
+ else
+ return 1;
+}
+
int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
struct kexec_info *info)
{
--
1.4.2
_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot