@@ -111,7 +111,20 @@ static int ping(int argc, char **argv)
111111 return 0 ;
112112}
113113
114- static void print_security_config (struct switchtec_security_cfg_state * state )
114+ static const char * program_status_to_string (enum switchtec_otp_program_status s )
115+ {
116+ switch (s ) {
117+ case SWITCHTEC_OTP_PROGRAMMABLE :
118+ return "R/W (Programmable)" ;
119+ case SWITCHTEC_OTP_UNPROGRAMMABLE :
120+ return "R/O (Unprogrammable)" ;
121+ default :
122+ return "Unknown" ;
123+ }
124+ }
125+
126+ static void print_security_config (struct switchtec_security_cfg_state * state ,
127+ struct switchtec_security_cfg_otp_region * otp )
115128{
116129 int key_idx ;
117130 int i ;
@@ -194,6 +207,27 @@ static void print_security_config(struct switchtec_security_cfg_state *state)
194207 printf ("%02x" , state -> public_key [key_idx ][i ]);
195208 printf ("\n" );
196209 }
210+
211+ if (otp ) {
212+ printf ("\nOTP Region Program Status\n" );
213+ printf ("\tBasic Secure Settings %s%s\n" ,
214+ otp -> basic_valid ? "(Valid): " : "(Invalid):" ,
215+ program_status_to_string (otp -> basic ));
216+ printf ("\tMixed Version %s\t%s\n" ,
217+ otp -> mixed_ver_valid ? "(Valid): " : "(Invalid):" ,
218+ program_status_to_string (otp -> mixed_ver ));
219+ printf ("\tMain FW Version %s\t%s\n" ,
220+ otp -> main_fw_ver_valid ? "(Valid): " : "(Invalid):" ,
221+ program_status_to_string (otp -> main_fw_ver ));
222+ printf ("\tSecure Unlock Version %s%s\n" ,
223+ otp -> sec_unlock_ver_valid ? "(Valid): " : "(Invalid):" ,
224+ program_status_to_string (otp -> sec_unlock_ver ));
225+ for (i = 0 ; i < 4 ; i ++ ) {
226+ printf ("\tKMSK%d %s\t\t%s\n" , i ,
227+ otp -> kmsk_valid [i ]? "(Valid): " : "(Invalid):" ,
228+ program_status_to_string (otp -> kmsk [i ]));
229+ }
230+ }
197231}
198232
199233static void print_security_cfg_set (struct switchtec_security_cfg_set * set )
@@ -236,17 +270,25 @@ static int info(int argc, char **argv)
236270
237271 static struct {
238272 struct switchtec_dev * dev ;
273+ int verbose ;
239274 } cfg = {};
240275
241276 const struct argconfig_options opts [] = {
242277 DEVICE_OPTION_MFG ,
243- {NULL }
244- };
278+ {"verbose" , 'v' , "" , CFG_NONE , & cfg .verbose , no_argument ,
279+ "print additional chip information" },
280+ {NULL }};
245281
246- struct switchtec_security_cfg_state state = {};
282+ struct switchtec_security_cfg_state_ext ext_state = {};
247283
248284 argconfig_parse (argc , argv , CMD_DESC_INFO , opts , & cfg , sizeof (cfg ));
249285
286+ ret = switchtec_security_config_get_ext (cfg .dev , & ext_state );
287+ if (ret ) {
288+ switchtec_perror ("mfg info" );
289+ return ret ;
290+ }
291+
250292 phase_id = switchtec_boot_phase (cfg .dev );
251293 printf ("Current Boot Phase: \t\t\t%s\n" , phase_id_to_string (phase_id ));
252294
@@ -266,13 +308,23 @@ static int info(int argc, char **argv)
266308 return 0 ;
267309 }
268310
269- ret = switchtec_security_config_get (cfg .dev , & state );
270- if (ret ) {
271- switchtec_perror ("mfg info" );
272- return ret ;
311+ if (cfg .verbose ) {
312+ if (!ext_state .otp_valid ) {
313+ print_security_config (& ext_state .state , NULL );
314+ fprintf (stderr ,
315+ "\nAdditional (verbose) chip info is not available on this chip!\n\n" );
316+ } else if (phase_id != SWITCHTEC_BOOT_PHASE_FW ) {
317+ print_security_config (& ext_state .state , NULL );
318+ fprintf (stderr ,
319+ "\nAdditional (verbose) chip info is only available in the Main Firmware phase!\n\n" );
320+ } else {
321+ print_security_config (& ext_state .state , & ext_state .otp );
322+ }
323+
324+ return 0 ;
273325 }
274326
275- print_security_config (& state );
327+ print_security_config (& ext_state . state , NULL );
276328
277329 return 0 ;
278330}
@@ -714,7 +766,7 @@ static int state_set(int argc, char **argv)
714766 return -3 ;
715767 }
716768
717- print_security_config (& state );
769+ print_security_config (& state , NULL );
718770
719771 if (!cfg .assume_yes ) {
720772 fprintf (stderr ,
0 commit comments