kexec-tools: Use generic /proc/iomem code (x86_64)
This patch modifies the x86_64-specific code to use the new generic code.
Signed-off-by: Magnus Damm <[EMAIL PROTECTED]>
---
kexec/arch/x86_64/crashdump-x86_64.c | 63 ++++------------------------------
1 file changed, 8 insertions(+), 55 deletions(-)
--- 0006/kexec/arch/x86_64/crashdump-x86_64.c
+++ work/kexec/arch/x86_64/crashdump-x86_64.c 2006-11-17 16:42:01.000000000
+0900
@@ -58,41 +58,16 @@ static int exclude_crash_reserve_region(
* store in kexec_info */
static int get_kernel_paddr(struct kexec_info *info)
{
- const char iomem[]= "/proc/iomem";
- char line[MAX_LINE];
- FILE *fp;
- unsigned long long start, end;
-
- fp = fopen(iomem, "r");
- if (!fp) {
- fprintf(stderr, "Cannot open %s: %s\n", iomem, strerror(errno));
- return -1;
- }
- while(fgets(line, sizeof(line), fp) != 0) {
- char *str;
- int consumed, count;
- count = sscanf(line, "%Lx-%Lx : %n",
- &start, &end, &consumed);
- if (count != 2)
- continue;
- str = line + consumed;
-#ifdef DEBUG
- printf("%016Lx-%016Lx : %s",
- start, end, str);
-#endif
- if (memcmp(str, "Kernel code\n", 12) == 0) {
- info->kern_paddr_start = start;
+ uint64_t start;
+ if (kexec_iomem_single("Kernel code\n", &start, NULL) == 0) {
+ info->kern_paddr_start = start;
#ifdef DEBUG
- printf("kernel load physical addr start = 0x%016Lx\n",
- start);
+ printf("kernel load physical addr start = 0x%016Lx\n", start);
#endif
- fclose(fp);
- return 0;
- }
}
+
fprintf(stderr, "Cannot determine kernel physical load addr\n");
- fclose(fp);
return -1;
}
@@ -678,30 +653,8 @@ int load_crashdump_segments(struct kexec
int is_crashkernel_mem_reserved(void)
{
- 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");
+ uint64_t start, end;
- 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;
+ return kexec_iomem_single("Crash kernel\n", &start, &end) == 0 ?
+ (start != end) : 0;
}
_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot