[Skiboot] [PATCH v4 5/6] hdata/hdata_to_dt: Add -s option
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Tue Mar 22 16:48:57 AEDT 2016
hdata_to_dt handles legacy SPIRA data only. This patch adds
new option (-s) to handle new SPIRAH/S data.
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
hdata/test/hdata_to_dt.c | 80 +++++++++++++++++++++++++++++++-----------------
1 file changed, 52 insertions(+), 28 deletions(-)
diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c
index 38bf825..c68e5bb 100644
--- a/hdata/test/hdata_to_dt.c
+++ b/hdata/test/hdata_to_dt.c
@@ -125,43 +125,64 @@ static void undefined_bytes(void *p, size_t len)
int main(int argc, char *argv[])
{
- int fd, r;
- bool verbose = false, quiet = false, tree_only = false;
+ int fd, r, i = 0, opt_count = 0;
+ bool verbose = false, quiet = false, tree_only = false, new_spira = false;
- while (argv[1]) {
- if (strcmp(argv[1], "-v") == 0) {
+ while (argv[++i]) {
+ if (strcmp(argv[i], "-v") == 0) {
verbose = true;
- argv++;
- argc--;
- } else if (strcmp(argv[1], "-q") == 0) {
+ opt_count++;
+ } else if (strcmp(argv[i], "-q") == 0) {
quiet = true;
- argv++;
- argc--;
- } else if (strcmp(argv[1], "-t") == 0) {
+ opt_count++;
+ } else if (strcmp(argv[i], "-t") == 0) {
tree_only = true;
- argv++;
- argc--;
- } else
- break;
+ opt_count++;
+ } else if (strcmp(argv[i], "-s") == 0) {
+ new_spira = true;
+ opt_count++;
+ }
}
- if (argc != 3)
- errx(1, "Usage: hdata [-v|-q|-t] <spira-dump> <heap-dump>");
+ argc -= opt_count;
+ argv += opt_count;
+ if (argc != 3) {
+ errx(1, "Usage:\n"
+ " hdata [-v|-q|-t] <spira-dump> <heap-dump>\n"
+ " hdata -s [-v|-q|-t] <spirah-dump> <spiras-dump>\n");
+ }
/* Copy in spira dump (assumes little has changed!). */
- fd = open(argv[1], O_RDONLY);
- if (fd < 0)
- err(1, "opening %s", argv[1]);
- r = read(fd, &spira, sizeof(spira));
- if (r < sizeof(spira.hdr))
- err(1, "reading %s gave %i", argv[1], r);
- if (verbose)
- printf("verbose: read spira %u bytes\n", r);
- close(fd);
-
- undefined_bytes((void *)&spira + r, sizeof(spira) - r);
+ if (new_spira) {
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0)
+ err(1, "opening %s", argv[1]);
+ r = read(fd, &spirah, sizeof(spirah));
+ if (r < sizeof(spirah.hdr))
+ err(1, "reading %s gave %i", argv[1], r);
+ if (verbose)
+ printf("verbose: read spirah %u bytes\n", r);
+ close(fd);
+
+ undefined_bytes((void *)&spirah + r, sizeof(spirah) - r);
+
+ base_addr = be64_to_cpu(spirah.ntuples.hs_data_area.addr);
+ } else {
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0)
+ err(1, "opening %s", argv[1]);
+ r = read(fd, &spira, sizeof(spira));
+ if (r < sizeof(spira.hdr))
+ err(1, "reading %s gave %i", argv[1], r);
+ if (verbose)
+ printf("verbose: read spira %u bytes\n", r);
+ close(fd);
+
+ undefined_bytes((void *)&spira + r, sizeof(spira) - r);
+
+ base_addr = be64_to_cpu(spira.ntuples.heap.addr);
+ }
- base_addr = be64_to_cpu(spira.ntuples.heap.addr);
if (!base_addr)
errx(1, "Invalid base addr");
if (verbose)
@@ -181,6 +202,9 @@ int main(int argc, char *argv[])
spira_heap_size, spira_heap);
close(fd);
+ if (new_spira)
+ spiras = (struct spiras *)spira_heap;
+
if (quiet) {
fclose(stdout);
fclose(stderr);
--
2.5.0
More information about the Skiboot
mailing list