From patchwork Fri May 8 07:58:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 469914 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 25A701402A0 for ; Fri, 8 May 2015 18:09:09 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 0BA051A0E39 for ; Fri, 8 May 2015 18:09:09 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 253CA1A066C for ; Fri, 8 May 2015 18:08:56 +1000 (AEST) Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 May 2015 18:08:54 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 8 May 2015 18:08:53 +1000 Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id A6D952BB0051 for ; Fri, 8 May 2015 18:08:53 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t4888jGC44367874 for ; Fri, 8 May 2015 18:08:53 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t4888L3g014482 for ; Fri, 8 May 2015 18:08:21 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t4888KqO013513 for ; Fri, 8 May 2015 18:08:21 +1000 Received: from cyril.ozlabs.ibm.com (unknown [9.192.254.114]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 18BDBA03A8 for ; Fri, 8 May 2015 17:58:52 +1000 (AEST) From: Cyril Bur To: skiboot@lists.ozlabs.org Date: Fri, 8 May 2015 17:58:35 +1000 Message-Id: <1431071915-3917-5-git-send-email-cyril.bur@au1.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431071915-3917-1-git-send-email-cyril.bur@au1.ibm.com> References: <1431071915-3917-1-git-send-email-cyril.bur@au1.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15050808-0025-0000-0000-00000173C420 Subject: [Skiboot] [PATCH 4/4] external/pflash: allow the libffs TOC to operate on to be specified X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 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" On systems with multiple TOCs it may be useful to be able to specify which one should be operated on. Signed-off-by: Cyril Bur --- external/pflash/pflash.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c index 30cc142..5d07be8 100644 --- a/external/pflash/pflash.c +++ b/external/pflash/pflash.c @@ -29,6 +29,7 @@ static bool must_confirm = true; static bool dummy_run; static bool need_relock; static bool bmc_flash; +static uint32_t ffs_toc = 0; static int flash_side = 0; #ifdef __powerpc__ static bool using_sfc; @@ -137,9 +138,12 @@ static int open_partition(const char *name) /* Open libffs if needed */ if (!ffsh) { - rc = ffs_open_flash(fl_chip, 0, 0, &ffsh); + rc = ffs_open_flash(fl_chip, ffs_toc, 0, &ffsh); if (rc) { fprintf(stderr, "Error %d opening ffs !\n", rc); + if (ffs_toc) + fprintf(stderr, "You specified 0x%08x as the libffs TOC" + " looks like it doesn't exist\n", ffs_toc); return rc; } } @@ -546,6 +550,9 @@ static void print_help(const char *pname) printf("\t\t(Implicit for all other operations)\n\n"); printf("\t-S, --side\n"); printf("\t\tSide of the flash on which to operate, 0 (default) or 1\n\n"); + printf("\t-T, --toc\n"); + printf("\t\tlibffs TOC on which to operate, defaults to 0.\n"); + printf("\t\tleading 0x is required for interpretation of a hex value\n\n"); printf("\t-i, --info\n"); printf("\t\tDisplay some information about the flash.\n\n"); printf("\t-h, --help\n"); @@ -564,6 +571,7 @@ int main(int argc, char *argv[]) bool has_sfc = false, has_ast = false; bool no_action = false, tune = false; char *write_file = NULL, *read_file = NULL, *part_name = NULL; + bool ffs_toc_seen = false; int rc; while(1) { @@ -587,10 +595,11 @@ int main(int argc, char *argv[]) {"version", no_argument, NULL, 'v'}, {"debug", no_argument, NULL, 'g'}, {"side", required_argument, NULL, 'S'}, + {"toc", required_argument, NULL, 'T'}, }; int c, oidx = 0; - c = getopt_long(argc, argv, "a:s:P:r:43Eep:fdihlvbtgS:", + c = getopt_long(argc, argv, "a:s:P:r:43Eep:fdihlvbtgS:T:", long_opts, &oidx); if (c == EOF) break; @@ -655,6 +664,10 @@ int main(int argc, char *argv[]) case 'S': flash_side = atoi(optarg); break; + case 'T': + ffs_toc_seen = true; + ffs_toc = strtoul(optarg, NULL, 0); + break; default: exit(1); } @@ -728,6 +741,11 @@ int main(int argc, char *argv[]) exit(1); } + if (ffs_toc_seen && flash_side) { + fprintf(stderr, "--toc and --side are exclusive"); + exit(1); + } + /* If file specified but not size, get size from file */ if (write_file && !write_size) {