[Skiboot] [PATCH 2/4] external/pflash: show the partitions on the second side flash

Cyril Bur cyril.bur at au1.ibm.com
Fri May 8 17:58:33 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 | 49 ++++++++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index d6f46d3..689f428 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 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, 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", 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) {
@@ -118,6 +107,26 @@ static void print_flash_info(void)
 
 		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