@@ -1754,6 +1754,7 @@ ssize_t rshim_fifo_write(rshim_backend_t *bd, const char *buffer,
17541754
17551755static void rshim_work_handler (rshim_backend_t * bd )
17561756{
1757+ rsh_scratchpad3_t sp3 = { .word = 0 };
17571758 int rc ;
17581759
17591760 pthread_mutex_lock (& bd -> mutex );
@@ -1762,8 +1763,12 @@ static void rshim_work_handler(rshim_backend_t *bd)
17621763
17631764 if (bd -> keepalive && bd -> has_rshim && !bd -> debug_code && !bd -> drop_mode &&
17641765 !bd -> in_access_check ) {
1765- bd -> write_rshim (bd , RSHIM_CHANNEL , bd -> regs -> scratchpad1 ,
1766- RSHIM_KEEPALIVE_MAGIC_NUM , RSHIM_REG_SIZE_8B );
1766+ bd -> read_rshim (bd , RSHIM_CHANNEL , bd -> regs -> scratchpad3 ,
1767+ & sp3 .word , RSHIM_REG_SIZE_8B );
1768+ if (sp3 .dbg_cmd == RSH_DBG_CMD_NONE ) {
1769+ bd -> write_rshim (bd , RSHIM_CHANNEL , bd -> regs -> scratchpad1 ,
1770+ RSHIM_KEEPALIVE_MAGIC_NUM , RSHIM_REG_SIZE_8B );
1771+ }
17671772 bd -> keepalive = 0 ;
17681773 }
17691774
@@ -3316,13 +3321,12 @@ static void print_help(void)
33163321 printf ("\n" );
33173322 printf ("OPTIONS:\n" );
33183323 printf (" -b, --backend backend name (usb, pcie or pcie-lf)\n" );
3319- printf (" -c, --cmdmode run in command line mode\n" );
3320- printf (" -g, --get-debug get debug code\n" );
3321- printf (" -r, --reg <addr.[32|64] [value]> read/write register\n" );
3322- printf (" -s, --set-debug <0 | 1> set debug code\n" );
3324+ printf (" -c, --cmdmode command line mode" );
3325+ printf (" ('-c --help' for sub-commands)\n" );
33233326 printf (" -d, --device device to attach\n" );
33243327 printf (" -f, --foreground run in foreground\n" );
33253328 printf (" -F, --force run in force mode\n" );
3329+ printf (" -h, --help show help info\n" );
33263330 printf (" -i, --index use device path /dev/rshim<i>/\n" );
33273331 printf (" -l, --log-level log level" );
33283332 printf ("(0:none, 1:error, 2:warning, 3:notice, 4:debug)\n" );
@@ -3332,27 +3336,25 @@ static void print_help(void)
33323336
33333337int main (int argc , char * argv [])
33343338{
3335- static const char short_options [] = "b:cd:fgFhi :l:nr:sv " ;
3339+ static const char short_options [] = "b:cd:fFhi :l:nv " ;
33363340 static struct option long_options [] = {
33373341 { "backend" , required_argument , NULL , 'b' },
33383342 { "cmdmode" , no_argument , NULL , 'c' },
33393343 { "device" , required_argument , NULL , 'd' },
33403344 { "foreground" , no_argument , NULL , 'f' },
33413345 { "force" , no_argument , NULL , 'F' },
3342- { "get-debug" , no_argument , NULL , 'g' },
33433346 { "help" , no_argument , NULL , 'h' },
33443347 { "index" , required_argument , NULL , 'i' },
33453348 { "log-level" , required_argument , NULL , 'l' },
33463349 { "nonet" , no_argument , NULL , 'n' },
3347- { "reg" , required_argument , NULL , 'r' },
3348- { "set-debug" , required_argument , NULL , 's' },
33493350 { "version" , no_argument , NULL , 'v' },
33503351 { NULL , 0 , NULL , 0 }
33513352 };
33523353 int c , rc , pid_fd = -1 ;
33533354 pthread_t thread ;
33543355
33553356 /* Parse arguments. */
3357+ opterr = 0 ;
33563358 while ((c = getopt_long (argc , argv , short_options , long_options , NULL ))
33573359 != -1 ) {
33583360 switch (c ) {
@@ -3402,6 +3404,16 @@ int main(int argc, char *argv[])
34023404 printf ("Rshim Driver for BlueField SoC 2.0\n" );
34033405#endif
34043406 return 0 ;
3407+ case '?' :
3408+ if (!rshim_cmdmode ) {
3409+ if (optopt ) {
3410+ fprintf (stderr , "Invalid option: -%c\n" , optopt );
3411+ } else {
3412+ fprintf (stderr , "Invalid option\n" );
3413+ }
3414+ return - EINVAL ;
3415+ }
3416+ break ;
34053417 case 'h' :
34063418 default :
34073419 if (!rshim_cmdmode ) {
0 commit comments