[Skiboot] [PATCH V3 4/6] external/pflash: Show the partitions on the second side flash

Cyril Bur cyril.bur at au1.ibm.com
Fri May 22 15:30:15 AEST 2015


Currently pflash is unaware that that some platforms can have two sides of
flash and therefore doesn't include the ability to print it.

The ffs TOC at the start of the flash may contain a partition called
"OTHER_SIDE" which will start with the TOC for the second side. If OTHER_SIDE
is found pflash will dump that flash information too.

Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
 external/pflash/pflash.c | 52 +++++++++++++++++++++++++++++-------------------
 1 file changed, 32 insertions(+), 20 deletions(-)

diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 29a2775..3fedac0 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -69,32 +69,21 @@ static void check_confirm(void)
 	must_confirm = false;
 }
 
-static void print_flash_info(void)
+static void print_ffs_info(uint32_t toc_offset)
 {
-	uint32_t i;
+	struct ffs_handle *ffs_handle;
+	uint32_t other_side_offset = 0;
 	int rc;
+	uint32_t i;
 
-	printf("Flash info:\n");
-	printf("-----------\n");
-	printf("Name          = %s\n", fl_name);
-	printf("Total size    = %dMB \n", fl_total_size >> 20);
-	printf("Erase granule = %dKB \n", fl_erase_granule >> 10);
-
-	if (bmc_flash)
+	rc = ffs_open_flash(fl_chip, toc_offset, 0, &ffs_handle);
+	if (rc) {
+		fprintf(stderr, "Error %d opening ffs !\n", rc);
 		return;
-
-	if (!ffsh) {
-		rc = ffs_open_flash(fl_chip, 0, 0, &ffsh);
-		if (rc) {
-			fprintf(stderr, "Error %d opening ffs !\n", rc);
-			ffsh = NULL;
-		}
 	}
-	if (!ffsh)
-		return;
 
 	printf("\n");
-	printf("Partitions:\n");
+	printf("TOC at 0x%08x Partitions:\n", toc_offset);
 	printf("-----------\n");
 
 	for (i = 0;; i++) {
@@ -102,7 +91,7 @@ static void print_flash_info(void)
 		bool ecc;
 		char *name;
 
-		rc = ffs_part_info(ffsh, i, &name, &start, &size, &act, &ecc);
+		rc = ffs_part_info(ffs_handle, i, &name, &start, &size, &act, &ecc);
 		if (rc == FFS_ERR_PART_NOT_FOUND)
 			break;
 		if (rc) {
@@ -113,8 +102,31 @@ static void print_flash_info(void)
 		printf("ID=%02d %15s %08x..%08x (actual=%08x) %s\n",
 		       i, name, start, end, act, ecc ? "[ECC]" : "");
 
+		if (strcmp(name, "OTHER_SIDE") == 0)
+			other_side_offset = start;
+
 		free(name);
 	}
+
+	ffs_close(ffs_handle);
+
+	if (other_side_offset)
+		print_ffs_info(other_side_offset);
+}
+
+
+static void print_flash_info(void)
+{
+	printf("Flash info:\n");
+	printf("-----------\n");
+	printf("Name          = %s\n", fl_name);
+	printf("Total size    = %dMB \n", fl_total_size >> 20);
+	printf("Erase granule = %dKB \n", fl_erase_granule >> 10);
+
+	if (bmc_flash)
+		return;
+
+	print_ffs_info(0);
 }
 
 static void lookup_partition(const char *name)
-- 
1.9.1



More information about the Skiboot mailing list