diff mbox series

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

Message ID 20190807091001.2957-1-js07.lee@samsung.com (mailing list archive)
State New, archived
Headers show
Series mmc-utils: feature spec 5.0+, add secure removal type fileds to Extended CSD | expand

Commit Message

Jungseung Lee Aug. 7, 2019, 9:10 a.m. UTC
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@samsung.com>
---
 mmc.h      |  3 +++
 mmc_cmds.c | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)

Comments

Avri Altman Aug. 8, 2019, 7:56 a.m. UTC | #1
Hi,

> 
> 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@samsung.com>
> ---
>  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 ");
printf(" information is configured to be removed ");

> +		switch ((reg & EXT_CSD_CONFIG_SECRM_TYPE) >> 4) {
Maybe add an appropriate comment, e.g.
/* Bit [5:4]: Configure Secure Removal Type */

> +			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;
> +		}
>  	}
You forgot to parse the supported part - EXT_CSD_SUPPORTED_SECRM_TYPE


Thanks,
Avri
Chris Ball Aug. 8, 2019, 10:48 p.m. UTC | #2
Hi, thanks for the patch,

On Wed, Aug 07, 2019 at 06:10:01PM +0900, Jungseung Lee wrote:
> +				printf("by an overwriting the addressed locations"

No need for "an", just "by overwriting the addressed locations".

> +				printf("using a vendor defined\n");

Maybe "using a vendor defined function"?

Thanks,

- Chris.
Jungseung Lee Aug. 9, 2019, 2:43 a.m. UTC | #3
Hi,

On 8/9/19, Chris Ball <chris@printf.net> wrote:
> Hi, thanks for the patch,
>
> On Wed, Aug 07, 2019 at 06:10:01PM +0900, Jungseung Lee wrote:
>> +				printf("by an overwriting the addressed locations"
>
> No need for "an", just "by overwriting the addressed locations".
>
>> +				printf("using a vendor defined\n");
>
> Maybe "using a vendor defined function"?
All the sentences came from JEDEC specification. (JESD84-B51A)
Is it more natural to change?
>
> Thanks,
>
> - Chris.
> --
> Chris Ball   <http://printf.net/>
>
Thanks,
Chris Ball Aug. 9, 2019, 4:34 a.m. UTC | #4
Hi,

On Fri, Aug 09, 2019 at 11:43:49AM +0900, Jungseung Lee wrote:
> > On Wed, Aug 07, 2019 at 06:10:01PM +0900, Jungseung Lee wrote:
> >> +				printf("by an overwriting the addressed locations"
> >
> > No need for "an", just "by overwriting the addressed locations".
> >
> >> +				printf("using a vendor defined\n");
> >
> > Maybe "using a vendor defined function"?
> All the sentences came from JEDEC specification. (JESD84-B51A)
> Is it more natural to change?

Oh!  I didn't realize.  That's okay, then: thanks, pushed to mmc-utils master.

- Chris.
diff mbox series

Patch

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) {