diff options
author | Suzuki K. Poulose <suzuki@in.ibm.com> | 2011-06-16 16:15:13 +0530 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2011-06-17 06:59:53 +0900 |
commit | 9ec3fac7e8840fb31891ba49a626c5dd33e09e86 (patch) | |
tree | 88fae54a9b4218138d206130fc749569676a452e /kexec/arch/ppc/crashdump-powerpc.c | |
parent | 6b4ca6d55ca3c7a2fd5e6586274dab44e0ab24fb (diff) |
kexec-tools: powerpc: Use the #address-cells information to parsememory/reg
The format of memory/reg is based on the #address-cells,#size-cells. Currently,
the kexec-tools doesn't use the above values in parsing the memory/reg values.
Hence the kexec cannot handle cases where #address-cells, #size-cells are
different, (for e.g, PPC440X ).
This patch introduces a read_memory_region_limits(), which parses the
memory/reg contents based on the values of #address-cells and #size-cells.
Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/arch/ppc/crashdump-powerpc.c')
-rw-r--r-- | kexec/arch/ppc/crashdump-powerpc.c | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/kexec/arch/ppc/crashdump-powerpc.c b/kexec/arch/ppc/crashdump-powerpc.c index 1dd6485..77a01e1 100644 --- a/kexec/arch/ppc/crashdump-powerpc.c +++ b/kexec/arch/ppc/crashdump-powerpc.c @@ -81,7 +81,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) char fname[256]; char buf[MAXBYTES]; DIR *dir, *dmem; - FILE *file; + int fd; struct dirent *dentry, *mentry; int i, n, crash_rng_len = 0; unsigned long long start, end, cstart, cend; @@ -123,17 +123,16 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) if (strcmp(mentry->d_name, "reg")) continue; strcat(fname, "/reg"); - file = fopen(fname, "r"); - if (!file) { + fd = open(fname, O_RDONLY); + if (fd < 0) { perror(fname); closedir(dmem); closedir(dir); goto err; } - n = fread(buf, 1, MAXBYTES, file); - if (n < 0) { - perror(fname); - fclose(file); + n = read_memory_region_limits(fd, &start, &end); + if (n != 0) { + close(fd); closedir(dmem); closedir(dir); goto err; @@ -146,24 +145,6 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) goto err; } - /* - * FIXME: This code fails on platforms that - * have more than one memory range specified - * in the device-tree's /memory/reg property. - * or where the #address-cells and #size-cells - * are not identical. - * - * We should interpret the /memory/reg property - * based on the values of the #address-cells and - * #size-cells properites. - */ - if (n == (sizeof(unsigned long) * 2)) { - start = ((unsigned long *)buf)[0]; - end = start + ((unsigned long *)buf)[1]; - } else { - start = ((unsigned long long *)buf)[0]; - end = start + ((unsigned long long *)buf)[1]; - } if (start == 0 && end >= (BACKUP_SRC_END + 1)) start = BACKUP_SRC_END + 1; @@ -212,7 +193,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) = RANGE_RAM; memory_ranges++; } - fclose(file); + close(fd); } closedir(dmem); } |