pflash: Display volatile flag

Message ID 1507752297-76155-1-git-send-email-anoo@linux.vnet.ibm.com
State Accepted
Headers show
Series
  • pflash: Display volatile flag
Related show

Commit Message

Adriana Kobylak Oct. 11, 2017, 8:04 p.m.
The volatile flag was added to the pnor image to
indicate partitions that are cleared during a host
power off. Display this flag from the pflash command.

Change-Id: I6ff810cd869b199fe983fa82c399938c4d82d5b3
Signed-off-by: Adriana Kobylak <anoo@linux.vnet.ibm.com>
---
 external/pflash/pflash.c                      | 12 +++++++-----
 external/pflash/test/files/06-miscprint.ffs   |  1 +
 external/pflash/test/results/01-info.out      | 13 +++++++------
 external/pflash/test/results/06-miscprint.out |  9 +++++++++
 4 files changed, 24 insertions(+), 11 deletions(-)

Comments

Adriana Kobylak Oct. 11, 2017, 8:23 p.m. | #1
From: Adriana Kobylak <anoo@us.ibm.com>

The volatile flag was added to the pnor image to
indicate partitions that are cleared during a host
power off. Display this flag from the pflash command.

Change-Id: I6ff810cd869b199fe983fa82c399938c4d82d5b3
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
---
 external/ffspart/ffspart.c                    |  3 +++
 external/pflash/pflash.c                      | 12 +++++++-----
 external/pflash/test/files/06-miscprint.ffs   |  1 +
 external/pflash/test/results/01-info.out      | 13 +++++++------
 external/pflash/test/results/06-miscprint.out |  9 +++++++++
 libflash/ffs.h                                |  1 +
 libflash/libffs.c                             |  4 +++-
 libflash/libffs.h                             |  1 +
 8 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/external/ffspart/ffspart.c b/external/ffspart/ffspart.c
index 7703477..a477018 100644
--- a/external/ffspart/ffspart.c
+++ b/external/ffspart/ffspart.c
@@ -295,6 +295,9 @@ int main(int argc, char *argv[])
 			case 'F':
 				user.miscflags |= FFS_MISCFLAGS_REPROVISION;
 				break;
+			case 'L':
+				user.miscflags |= FFS_MISCFLAGS_VOLATILE;
+				break;
 			/* Not sure these are valid */
 			case 'B':
 				user.miscflags |= FFS_MISCFLAGS_BACKUP;
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 5b1be3c..d6b2b8e 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -115,12 +115,13 @@ static uint32_t print_ffs_info(struct ffs_handle *ffsh, uint32_t toc)
 		    goto out;
 		}
 
-		l = asprintf(&flags, "[%c%c%c%c%c]",
+		l = asprintf(&flags, "[%c%c%c%c%c%c]",
 				has_ecc(ent) ? 'E' : '-',
 				has_flag(ent, FFS_MISCFLAGS_PRESERVED) ? 'P' : '-',
 				has_flag(ent, FFS_MISCFLAGS_READONLY) ? 'R' : '-',
 				has_flag(ent, FFS_MISCFLAGS_BACKUP) ? 'B' : '-',
-				has_flag(ent, FFS_MISCFLAGS_REPROVISION) ? 'F' : '-');
+				has_flag(ent, FFS_MISCFLAGS_REPROVISION) ? 'F' : '-',
+				has_flag(ent, FFS_MISCFLAGS_VOLATILE) ? 'V' : '-');
 		if (l < 0)
 			goto out;
 
@@ -169,7 +170,7 @@ static void print_flash_info(struct flash_details *flash)
 	printf("Name          = %s\n", flash->name);
 	printf("Total size    = %" PRIu64 "MB\t Flags E:ECC, P:PRESERVED, R:READONLY\n",
 			flash->total_size >> 20);
-	printf("Erase granule = %2d%-13sB:BACKUP, F:REPROVISION\n",
+	printf("Erase granule = %2d%-13sB:BACKUP, F:REPROVISION, V:VOLATILE\n",
 			flash->erase_granule >> 10, "KB");
 
 	if (bmc_flash)
@@ -576,12 +577,13 @@ static void print_partition_detail(struct ffs_handle *ffsh, uint32_t part_id)
 
 	printf("Flags:\n");
 
-	l = asprintf(&flags, "%s%s%s%s%s", has_ecc(ent) ? "ECC [E]\n" : "",
+	l = asprintf(&flags, "%s%s%s%s%s%s", has_ecc(ent) ? "ECC [E]\n" : "",
 			has_flag(ent, FFS_MISCFLAGS_PRESERVED) ? "PRESERVED [P]\n" : "",
 			has_flag(ent, FFS_MISCFLAGS_READONLY) ? "READONLY [R]\n" : "",
 			has_flag(ent, FFS_MISCFLAGS_BACKUP) ? "BACKUP [B]\n" : "",
 			has_flag(ent, FFS_MISCFLAGS_REPROVISION) ?
-					"REPROVISION [F]\n" : "");
+					"REPROVISION [F]\n" : "",
+			has_flag(ent, FFS_MISCFLAGS_VOLATILE) ? "VOLATILE [V]\n" : "");
 	if (l < 0) {
 		fprintf(stderr, "Memory allocation failure printing flags!\n");
 		goto out;
diff --git a/external/pflash/test/files/06-miscprint.ffs b/external/pflash/test/files/06-miscprint.ffs
index 8f916f3..a0bd944 100644
--- a/external/pflash/test/files/06-miscprint.ffs
+++ b/external/pflash/test/files/06-miscprint.ffs
@@ -2,3 +2,4 @@ PRESERVED,0x00300,0x100,P,/dev/zero
 READONLY,0x000400,0x100,R,/dev/zero
 REPROVISION,0x500,0x100,F,/dev/zero
 BACKUP,0x00000600,0x100,B,/dev/zero
+VOLATILE,0x00000700,0x100,V,/dev/zero
diff --git a/external/pflash/test/results/01-info.out b/external/pflash/test/results/01-info.out
index 43baf31..ba4c6fa 100644
--- a/external/pflash/test/results/01-info.out
+++ b/external/pflash/test/results/01-info.out
@@ -2,12 +2,13 @@ Flash info:
 -----------
 Name          = FILE
 Total size    = 0MB	 Flags E:ECC, P:PRESERVED, R:READONLY
-Erase granule =  0KB           B:BACKUP, F:REPROVISION
+Erase granule =  0KB           B:BACKUP, F:REPROVISION, V:VOLATILE
 
 TOC@0x00000000 Partitions:
 -----------
-ID=00            part 0x00000000..0x00000300 (actual=0x00000300) [-----]
-ID=01             ONE 0x00000300..0x00000400 (actual=0x00000100) [E----]
-ID=02             TWO 0x00000400..0x00000500 (actual=0x00000100) [E---F]
-ID=03           THREE 0x00000500..0x00000600 (actual=0x00000100) [E---F]
-ID=04            FOUR 0x00000600..0x00000700 (actual=0x00000100) [E---F]
+ID=00            part 0x00000000..0x00000300 (actual=0x00000300) [------]
+ID=01             ONE 0x00000300..0x00000400 (actual=0x00000100) [E-----]
+ID=02             TWO 0x00000400..0x00000500 (actual=0x00000100) [E---F-]
+ID=03           THREE 0x00000500..0x00000600 (actual=0x00000100) [E---F-]
+ID=04            FOUR 0x00000600..0x00000700 (actual=0x00000100) [E---F-]
+ID=05            FIVE 0x00000700..0x00000800 (actual=0x00000100) [-----V]
diff --git a/external/pflash/test/results/06-miscprint.out b/external/pflash/test/results/06-miscprint.out
index e90976d..58aeaf9 100644
--- a/external/pflash/test/results/06-miscprint.out
+++ b/external/pflash/test/results/06-miscprint.out
@@ -34,3 +34,12 @@ Start       End         Actual
 
 Flags:
 BACKUP [B]
+Detailed partition information
+Name:
+VOLATILE (ID=05)
+
+Start       End         Actual    
+0x00000700  0x00000800  0x00000100
+
+Flags:
+VOLATILE [V]
diff --git a/libflash/ffs.h b/libflash/ffs.h
index 1872253..26cb9d8 100644
--- a/libflash/ffs.h
+++ b/libflash/ffs.h
@@ -76,6 +76,7 @@ enum ffs_type {
 #define FFS_MISCFLAGS_READONLY 0x40
 #define FFS_MISCFLAGS_BACKUP 0x20
 #define FFS_MISCFLAGS_REPROVISION 0x10
+#define FFS_MISCFLAGS_VOLATILE 0x08
 
 /**
  * struct __ffs_entry_user - On flash user data entries
diff --git a/libflash/libffs.c b/libflash/libffs.c
index 038f594..87c5197 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -723,7 +723,9 @@ int ffs_entry_user_set(struct ffs_entry *ent, struct ffs_entry_user *user)
 	if (user->vercheck & ~(FFS_VERCHECK_SHA512V | FFS_VERCHECK_SHA512EC))
 		return -1;
 	if (user->miscflags & ~(FFS_MISCFLAGS_PRESERVED | FFS_MISCFLAGS_BACKUP |
-				FFS_MISCFLAGS_READONLY | FFS_MISCFLAGS_REPROVISION))
+				FFS_MISCFLAGS_READONLY | FFS_MISCFLAGS_REPROVISION |
+				FFS_MISCFLAGS_VOLATILE
+))
 		return -1;
 
 	memcpy(&ent->user, user, sizeof(*user));
diff --git a/libflash/libffs.h b/libflash/libffs.h
index a0f65a0..0610399 100644
--- a/libflash/libffs.h
+++ b/libflash/libffs.h
@@ -88,6 +88,7 @@ struct ffs_entry_user {
 #define FFS_MISCFLAGS_READONLY 0x40
 #define FFS_MISCFLAGS_BACKUP 0x20
 #define FFS_MISCFLAGS_REPROVISION 0x10
+#define FFS_MISCFLAGS_VOLATILE 0x08
 
 
 bool has_ecc(struct ffs_entry *ent);
Stewart Smith Nov. 10, 2017, 4:28 a.m. | #2
Adriana Kobylak <anoo@linux.vnet.ibm.com> writes:
> From: Adriana Kobylak <anoo@us.ibm.com>
>
> The volatile flag was added to the pnor image to
> indicate partitions that are cleared during a host
> power off. Display this flag from the pflash command.
>
> Change-Id: I6ff810cd869b199fe983fa82c399938c4d82d5b3
> Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
> ---
>  external/ffspart/ffspart.c                    |  3 +++
>  external/pflash/pflash.c                      | 12 +++++++-----
>  external/pflash/test/files/06-miscprint.ffs   |  1 +
>  external/pflash/test/results/01-info.out      | 13 +++++++------
>  external/pflash/test/results/06-miscprint.out |  9 +++++++++
>  libflash/ffs.h                                |  1 +
>  libflash/libffs.c                             |  4 +++-
>  libflash/libffs.h                             |  1 +
>  8 files changed, 32 insertions(+), 12 deletions(-)

Looks okay to me.

Casually wished Cyril would chime in, but now if he disagrees he gets to
send patches instead :)

Merged to master as of b786e7ba1d34c5a4d8baa6304f4d930539cefac8

Patch

diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 5b1be3c..d6b2b8e 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -115,12 +115,13 @@  static uint32_t print_ffs_info(struct ffs_handle *ffsh, uint32_t toc)
 		    goto out;
 		}
 
-		l = asprintf(&flags, "[%c%c%c%c%c]",
+		l = asprintf(&flags, "[%c%c%c%c%c%c]",
 				has_ecc(ent) ? 'E' : '-',
 				has_flag(ent, FFS_MISCFLAGS_PRESERVED) ? 'P' : '-',
 				has_flag(ent, FFS_MISCFLAGS_READONLY) ? 'R' : '-',
 				has_flag(ent, FFS_MISCFLAGS_BACKUP) ? 'B' : '-',
-				has_flag(ent, FFS_MISCFLAGS_REPROVISION) ? 'F' : '-');
+				has_flag(ent, FFS_MISCFLAGS_REPROVISION) ? 'F' : '-',
+				has_flag(ent, FFS_MISCFLAGS_VOLATILE) ? 'V' : '-');
 		if (l < 0)
 			goto out;
 
@@ -169,7 +170,7 @@  static void print_flash_info(struct flash_details *flash)
 	printf("Name          = %s\n", flash->name);
 	printf("Total size    = %" PRIu64 "MB\t Flags E:ECC, P:PRESERVED, R:READONLY\n",
 			flash->total_size >> 20);
-	printf("Erase granule = %2d%-13sB:BACKUP, F:REPROVISION\n",
+	printf("Erase granule = %2d%-13sB:BACKUP, F:REPROVISION, V:VOLATILE\n",
 			flash->erase_granule >> 10, "KB");
 
 	if (bmc_flash)
@@ -576,12 +577,13 @@  static void print_partition_detail(struct ffs_handle *ffsh, uint32_t part_id)
 
 	printf("Flags:\n");
 
-	l = asprintf(&flags, "%s%s%s%s%s", has_ecc(ent) ? "ECC [E]\n" : "",
+	l = asprintf(&flags, "%s%s%s%s%s%s", has_ecc(ent) ? "ECC [E]\n" : "",
 			has_flag(ent, FFS_MISCFLAGS_PRESERVED) ? "PRESERVED [P]\n" : "",
 			has_flag(ent, FFS_MISCFLAGS_READONLY) ? "READONLY [R]\n" : "",
 			has_flag(ent, FFS_MISCFLAGS_BACKUP) ? "BACKUP [B]\n" : "",
 			has_flag(ent, FFS_MISCFLAGS_REPROVISION) ?
-					"REPROVISION [F]\n" : "");
+					"REPROVISION [F]\n" : "",
+			has_flag(ent, FFS_MISCFLAGS_VOLATILE) ? "VOLATILE [V]\n" : "");
 	if (l < 0) {
 		fprintf(stderr, "Memory allocation failure printing flags!\n");
 		goto out;
diff --git a/external/pflash/test/files/06-miscprint.ffs b/external/pflash/test/files/06-miscprint.ffs
index 8f916f3..a0bd944 100644
--- a/external/pflash/test/files/06-miscprint.ffs
+++ b/external/pflash/test/files/06-miscprint.ffs
@@ -2,3 +2,4 @@  PRESERVED,0x00300,0x100,P,/dev/zero
 READONLY,0x000400,0x100,R,/dev/zero
 REPROVISION,0x500,0x100,F,/dev/zero
 BACKUP,0x00000600,0x100,B,/dev/zero
+VOLATILE,0x00000700,0x100,V,/dev/zero
diff --git a/external/pflash/test/results/01-info.out b/external/pflash/test/results/01-info.out
index 43baf31..ba4c6fa 100644
--- a/external/pflash/test/results/01-info.out
+++ b/external/pflash/test/results/01-info.out
@@ -2,12 +2,13 @@  Flash info:
 -----------
 Name          = FILE
 Total size    = 0MB	 Flags E:ECC, P:PRESERVED, R:READONLY
-Erase granule =  0KB           B:BACKUP, F:REPROVISION
+Erase granule =  0KB           B:BACKUP, F:REPROVISION, V:VOLATILE
 
 TOC@0x00000000 Partitions:
 -----------
-ID=00            part 0x00000000..0x00000300 (actual=0x00000300) [-----]
-ID=01             ONE 0x00000300..0x00000400 (actual=0x00000100) [E----]
-ID=02             TWO 0x00000400..0x00000500 (actual=0x00000100) [E---F]
-ID=03           THREE 0x00000500..0x00000600 (actual=0x00000100) [E---F]
-ID=04            FOUR 0x00000600..0x00000700 (actual=0x00000100) [E---F]
+ID=00            part 0x00000000..0x00000300 (actual=0x00000300) [------]
+ID=01             ONE 0x00000300..0x00000400 (actual=0x00000100) [E-----]
+ID=02             TWO 0x00000400..0x00000500 (actual=0x00000100) [E---F-]
+ID=03           THREE 0x00000500..0x00000600 (actual=0x00000100) [E---F-]
+ID=04            FOUR 0x00000600..0x00000700 (actual=0x00000100) [E---F-]
+ID=05            FIVE 0x00000700..0x00000800 (actual=0x00000100) [-----V]
diff --git a/external/pflash/test/results/06-miscprint.out b/external/pflash/test/results/06-miscprint.out
index e90976d..58aeaf9 100644
--- a/external/pflash/test/results/06-miscprint.out
+++ b/external/pflash/test/results/06-miscprint.out
@@ -34,3 +34,12 @@  Start       End         Actual
 
 Flags:
 BACKUP [B]
+Detailed partition information
+Name:
+VOLATILE (ID=05)
+
+Start       End         Actual    
+0x00000700  0x00000800  0x00000100
+
+Flags:
+VOLATILE [V]