예제 #1
0
int Main(void)
{
	char *cmd[8];
	int cmdcnt;
	char buff[32];

	init();
	start();
	puts(help[0]);
	init_taglist(0x40000000);
	while(1)
	{
		puts("IMX233# ");
		cmdcnt = cmdline(cmd);
		if (cmdcnt == 1 && strcmp(cmd[0], "h") == 0)
		{
			int i;

			for (i = 0; i < 3; i++)
			{
				puts("\r\n");
				puts(help[i]);
			}
		}
		if (cmdcnt == 2 && strcmp(cmd[0], "get") == 0)
		{	
			cmd_get(cmd[1]);
		}
		if (cmdcnt == 2 && strcmp(cmd[0], "go") == 0)
		{
			cmd_go(cmd[1]);
		}
		if (cmdcnt == 1 && strcmp(cmd[0], "ddr") == 0)
		{
			ddrtest();
		}
		putchr('\n');
		putchr('\r');

	}

	return 0;
}
예제 #2
0
void
GameEvent(CORE_DATA *cd)
{
	switch (cd->event) {
	case EVENT_START:
		RegisterPlugin(OPENCORE_VERSION, CORE_NAME, "cycad", OPENCORE_VERSION, __DATE__, __TIME__, "core handler", 0, 0);
		register_commands();
		break;
	case EVENT_COMMAND:
		switch (cd->cmd_id) {
		case CMD_DIE: cmd_die(cd); break;
		case CMD_STOPBOT: cmd_stopbot(cd); break;
		case CMD_GETFILE: cmd_getfile(cd); break;
		case CMD_PUTFILE: cmd_putfile(cd); break;
		case CMD_LISTBOTS: cmd_listbots(cd); break;
		case CMD_TYPES: cmd_types(cd); break;
		case CMD_LOADTYPES: cmd_loadtypes(cd); break;
		case CMD_LOG: cmd_log(cd); break;
		case CMD_CMDLOG: cmd_cmdlog(cd); break;
		case CMD_ABOUT: cmd_about(cd); break;
		case CMD_INSLIB: cmd_inslib(cd); break;
		case CMD_RMLIB: cmd_rmlib(cd); break;
		case CMD_HELP: cmd_help(cd); break;
		case CMD_SYSINFO: cmd_sysinfo(cd); break;
		case CMD_LOADOPS: cmd_loadops(cd); break;
		case CMD_LISTOPS: cmd_listops(cd); break;
		case CMD_EXEC: cmd_exec(cd); break;
		case CMD_STARTBOT: cmd_startbot(cd); break;
		case CMD_GO: cmd_go(cd); break;
		default: break;
		}
		break;
	default:
		break;
	}
}
예제 #3
0
static void console_command_mode_run(void)
{
  char szTemp[256];
  char *str = NULL;
  int len = 0, i = 0;


  OS_PRINTF("\nEnter command mode. 'help' to show command list(non specific)\n");
  OS_PRINTF("\nEnter command mode. 'spechelp' to show specific command list\n");
  
  while (1)
  {
    if(get_console_mode() == DOWNLOAD_MODE)
    {
      OS_PRINTF("> ");
    }
    else
    {
      OS_PRINTF("Cmd > ");
    }
    get_command(szTemp);
#ifdef ENABLE_CMD_HISTORY
    save_command(szTemp);
#endif
    len = strlen(szTemp);

    if(len <= 0)
    {
      // do nothing
      continue;
    }

    // trim the space at the begin of the input
    for(i = 0; i < len; i++)
    {
      if(szTemp[i] != ' ')
      {
        str = &szTemp[i];
        break;
      }
    }

    // trim the space at the end of the input
    for(i = len-1; i >= 0; i--)
    {
      if(szTemp[i] != ' ')
      {
        szTemp[i+1] = 0;
        break;
      }
    }
    
    len = strlen(str);

    if(len <= 0)
    {
      continue;
      // do nothing
    }
    else
    {
      int i = 0, j =0;
      int showhelp = 0;
      testfm_p_suite_t pSuite = NULL;
      testfm_p_cmd_t pTest = NULL;
      testfm_error_code_t res = TESTFM_SUCCESS;


      if(!(((str[0] >= 'a') && (str[0] <= 'z')) || ((str[0] >= 'A') && (str[0] <= 'Z'))))
      {
        OS_PRINTF("CMD should start with 'a-z' and 'A-Z'.\n");
        continue;
      }

      for(i = 0; i < len-1; i++)
      {
        if((j == 0) && (str[i] == ' '))
        {
          j = i;
          memset(parameter_str, 0, 256);
          memcpy(parameter_str, &str[i+1], strlen(&str[i+1]));
        }

        if((str[i] == '-') && (str[i+1]  == 'h') && (str[i-1] == ' ') 
             && (((i+2) == len) || (str[i+2] == ' ')))
        {
          showhelp = 1;
          break;
        }
      }
      if(j != 0)
        str[j] = 0;

      if(0 == memcmp(str, "help", 4))
      {
        // list all non specific command
        cmd_help();
        continue;
      }
      if(0 == memcmp(str, "wizardshelp", 11))
      {
    	  // list all specific command
    	  cmd_help_specific(PLATFORM_WIZARD);
    	  continue;
      }
      if(0 == memcmp(str, "magichelp", 9))
           {
         	  // list all specific command
         	  cmd_help_specific(PLATFORM_MAGIC);
         	  continue;
           }
      if(0 == memcmp(str, "warriorshelp", 12))
           {
         	  // list all specific command
         	  cmd_help_specific(PLATFORM_WARRIORS);
         	  continue;
           }
      if(0 == memcmp(str, "anyhelp", 7))
           {
         	  // list all specific command
         	  cmd_help_specific(PLATFORM_ANY);
         	  continue;
           }

      if(0 == memcmp(str, "read", 4))
      {
        cmd_read();
        continue;
      }

      if(0 == memcmp(str, "write", 5))
      {
        //cmd_write();
        continue;
      }

      if(get_console_mode() == DOWNLOAD_MODE)
      {
        if(0 == memcmp(str, "download", 8))
        {
          cmd_download();
          continue;
        }

        if(0 == memcmp(str, "go", 2))
        {
          cmd_go();
          continue;
        }
        
        if(0 == memcmp(str, "reboot", 6))
        {
          cmd_reboot();
          continue;
        }

        OS_PRINTF("'%s' is not recognized as an internal or external command.\n", str);
        continue;
      }
      

      if(0 == memcmp(str, "exit", 4))
      {
        cmd_exit();
        continue;
      }

      if(0 == memcmp(str, "runall", 6))
      {
        cmd_runall();
        continue;
      }

      if(0 == memcmp(str, "statistic", 9))
      {
        cmd_statistic();
        continue;
      }

      if(0 == memcmp(str, "autorun", 7))
      {
        //cmd_autorun();
        continue;
      }

       // add the reboot cmd for white box test
      if(0 == memcmp(str, "reboot", 6))
      {
        cmd_reboot();
        continue;
      }

      if(testfm_find_cmd(str, &pSuite, &pTest) == FALSE)
      {
        OS_PRINTF("'%s' is not recognized as an internal or external command.\n", str);
      }
      else
      {
        if(showhelp == 1)
        {
          pTest->pHelpFunc();
        }
        else
        {
          //OS_PRINTF(", name: %s\n", pTest->pName);
          res = testfm_run_cmd(pSuite, pTest);
          if(res != TESTFM_SUCCESS)
            OS_PRINTF("error code: %d\n", res);
        }
      }
 
    }
  }
}