[PATCH] mmc-utils: feature spec 5.0+, add secure removal type fileds to Extended CSD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Display secure removal type when printing Extended CSD
Example:
	# mmc extcsd read /dev/mmcblk0
	...
	Secure Removal Type [SECURE_REMOVAL_TYPE]: 0x39
	 information removed using a vendor defined

Signed-off-by: Jungseung Lee <js07.lee@xxxxxxxxxxx>
---
 mmc.h      |  3 +++
 mmc_cmds.c | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/mmc.h b/mmc.h
index 285c1f1..648fb26 100644
--- a/mmc.h
+++ b/mmc.h
@@ -116,6 +116,7 @@
 #define EXT_CSD_MODE_CONFIG		30
 #define EXT_CSD_MODE_OPERATION_CODES	29	/* W */
 #define EXT_CSD_FFU_STATUS		26	/* R */
+#define EXT_CSD_SECURE_REMOVAL_TYPE	16	/* R/W */
 #define EXT_CSD_CMDQ_MODE_EN		15	/* R/W */
 
 /*
@@ -132,6 +133,8 @@
 /*
  * EXT_CSD field definitions
  */
+#define EXT_CSD_CONFIG_SECRM_TYPE	(0x30)
+#define EXT_CSD_SUPPORTED_SECRM_TYPE	(0x0f)
 #define EXT_CSD_FFU_INSTALL		(0x01)
 #define EXT_CSD_FFU_MODE		(0x01)
 #define EXT_CSD_NORMAL_MODE		(0x00)
diff --git a/mmc_cmds.c b/mmc_cmds.c
index 19a9da1..8d6455e 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -1766,6 +1766,25 @@ int do_read_extcsd(int nargs, char **argv)
 			ext_csd[EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B]);
 		printf("eMMC Pre EOL information [EXT_CSD_PRE_EOL_INFO]: 0x%02x\n",
 			ext_csd[EXT_CSD_PRE_EOL_INFO]);
+		reg = ext_csd[EXT_CSD_SECURE_REMOVAL_TYPE];
+		printf("Secure Removal Type [SECURE_REMOVAL_TYPE]: 0x%02x\n", reg);
+		printf(" information removed ");
+		switch ((reg & EXT_CSD_CONFIG_SECRM_TYPE) >> 4) {
+			case 0x0:
+				printf("by an erase of the physical memory\n");
+				break;
+			case 0x1:
+				printf("by an overwriting the addressed locations"
+				       " with a character followed by an erase\n");
+				break;
+			case 0x2:
+				printf("by an overwriting the addressed locations"
+				       " with a character, its complement, then a random character\n");
+				break;
+			case 0x3:
+				printf("using a vendor defined\n");
+				break;
+		}
 	}
 
 	if (ext_csd_rev >= 8) {
-- 
2.17.1




[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux