diff options
Diffstat (limited to 'kexec/arch/x86_64/crashdump-x86_64.c')
-rw-r--r-- | kexec/arch/x86_64/crashdump-x86_64.c | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/kexec/arch/x86_64/crashdump-x86_64.c b/kexec/arch/x86_64/crashdump-x86_64.c index f104b89..3d0f3a5 100644 --- a/kexec/arch/x86_64/crashdump-x86_64.c +++ b/kexec/arch/x86_64/crashdump-x86_64.c @@ -30,12 +30,11 @@ #include "../../kexec.h" #include "../../kexec-elf.h" #include "../../kexec-syscall.h" +#include "../../crashdump.h" #include "kexec-x86_64.h" #include "crashdump-x86_64.h" #include <x86/x86-linux.h> -#define MAX_LINE 160 - extern struct arch_options_t arch_options; /* Forward Declaration. */ @@ -471,44 +470,6 @@ static int cmdline_add_memmap_acpi(char *cmdline, unsigned long start, return 0; } -/* Returns the virtual address of start of crash notes buffer for a cpu. */ -static int get_crash_notes_section_addr(int cpu, unsigned long long *addr) -{ - -#define MAX_SYSFS_PATH_LEN 70 - char crash_notes[MAX_SYSFS_PATH_LEN]; - char line[MAX_LINE]; - FILE *fp; - struct stat cpu_stat; - - sprintf(crash_notes, "/sys/devices/system/cpu"); - if (stat(crash_notes, &cpu_stat)) { - die("Cannot stat %s: %s\nTry mounting sysfs\n", - crash_notes, strerror(errno)); - } - - sprintf(crash_notes, "/sys/devices/system/cpu/cpu%d/crash_notes", cpu); - fp = fopen(crash_notes, "r"); - if (!fp) { - /* CPU is not physically present.*/ - *addr = 0; - return -1; - } - - if (fgets(line, sizeof(line), fp) != 0) { - int count; - count = sscanf(line, "%Lx", addr); - if (count != 1) { - *addr = 0; - return -1; - } -#if 0 - printf("crash_notes addr = %Lx\n", *addr); -#endif - } - return 0; -} - /* Prepares the crash memory elf64 headers and stores in supplied buffer. */ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, void *buf, unsigned long size) @@ -518,7 +479,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, int i; char *bufp; long int nr_cpus = 0; - unsigned long long notes_addr; + uint64_t notes_addr; bufp = (char*) buf; @@ -554,7 +515,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, /* Need to find a better way to determine per cpu notes section size. */ #define MAX_NOTE_BYTES 1024 for (i = 0; i < nr_cpus; i++) { - if (get_crash_notes_section_addr (i, ¬es_addr) < 0) { + if (get_crash_notes_per_cpu(i, ¬es_addr) < 0) { /* This cpu is not present. Skip it. */ continue; } @@ -624,7 +585,7 @@ static int prepare_crash_memory_elf32_headers(struct kexec_info *info, int i; char *bufp; long int nr_cpus = 0; - unsigned long long notes_addr; + uint64_t notes_addr; bufp = (char*) buf; @@ -660,7 +621,7 @@ static int prepare_crash_memory_elf32_headers(struct kexec_info *info, /* Need to find a better way to determine per cpu notes section size. */ #define MAX_NOTE_BYTES 1024 for (i = 0; i < nr_cpus; i++) { - if (get_crash_notes_section_addr (i, ¬es_addr) < 0) { + if (get_crash_notes_per_cpu(i, ¬es_addr) < 0) { /* This cpu is not present. Skip it. */ return -1; } |