From patchwork Wed Mar 9 14:27:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 595083 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 65134140BB9 for ; Thu, 10 Mar 2016 01:29:33 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3C54A1A035B for ; Thu, 10 Mar 2016 01:29:33 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp05.au.ibm.com (e23smtp05.au.ibm.com [202.81.31.147]) (using TLSv1.2 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id B2B571A02BF for ; Thu, 10 Mar 2016 01:28:59 +1100 (AEDT) Received: from localhost by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Mar 2016 00:28:59 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp05.au.ibm.com (202.81.31.211) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 10 Mar 2016 00:28:58 +1000 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: hegdevasant@linux.vnet.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id A763B2CE8054 for ; Thu, 10 Mar 2016 01:28:57 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u29ESnN711534644 for ; Thu, 10 Mar 2016 01:28:57 +1100 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u29ESOWi022583 for ; Thu, 10 Mar 2016 01:28:25 +1100 Received: from hegdevasant.ibm.com ([9.80.64.109]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u29ESDdn021878; Thu, 10 Mar 2016 01:28:23 +1100 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Wed, 9 Mar 2016 19:57:47 +0530 Message-Id: <1457533668-10655-6-git-send-email-hegdevasant@linux.vnet.ibm.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457533668-10655-1-git-send-email-hegdevasant@linux.vnet.ibm.com> References: <1457533668-10655-1-git-send-email-hegdevasant@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16030914-0017-0000-0000-0000030496C2 Subject: [Skiboot] [PATCH v3 5/6] hdata/hdata_to_dt: Add -s option X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" 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 --- 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] "); + argc -= opt_count; + argv += opt_count; + if (argc != 3) { + errx(1, "Usage:\n" + " hdata [-v|-q|-t] \n" + " hdata -s [-v|-q|-t] \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);