[Skiboot] [PATCH 4/4] external/pflash: allow the libffs TOC to operate on to be specified

Cyril Bur cyril.bur at au1.ibm.com
Fri May 8 17:58:35 AEST 2015


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 <cyril.bur at au1.ibm.com>
---
 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) {
-- 
1.9.1



More information about the Skiboot mailing list