int main(int argc, char** argv){ Cpu& cpu = *Cpu::create_cpu(); bool end = false; char line[512]; while (!end && !cin.eof() && cin.getline(line, 512)){ switch (line[0]){ case 'r': cmd_reg(line, *cpu.getMips()); break; case 'p': cmd_pc(line, *cpu.getMips()); break; case 'm': cmd_mem(line, *cpu.getMem()); break; case '.': cmd_exe(line, cpu); break; case 'q': end = true; break; default: COMMAND_UNKNOWN(); }; } Cpu::delete_cpu(&cpu); return EXIT_SUCCESS; };
void console_runcmd(console_t* console, char* cmdline, int* fat, unsigned int memtotal) { /* execute command */ if (0 == strcmp("mem", cmdline)) { /* check memory command */ cmd_mem(console, memtotal); } else if (0 == strcmp("clear", cmdline)) { /* clear command */ cmd_clear(console); } else if (0 == strcmp("ls", cmdline)) { /* ls(dir) command */ cmd_ls(console); } else if (0 == strncmp("cat ", cmdline, 4)) { /* cat command */ cmd_cat(console, fat, cmdline); } else if (0 != cmdline[0]) { if (0 == cmd_app(console, fat, cmdline)) { /* neither command nor null string */ console_putstr0(console, "Bad Command.\n\n"); } } }
//执行指定指令的函数 void console_runcmd(char *cmdline, CONSOLE *console, int *fat, unsigned int mem_total) { if(0 == strcmp(cmdline, "mem")) { cmd_mem(console, mem_total); } else if(0 == strcmp(cmdline, "clear")) { cmd_clear(console); } else if(0 == strcmp(cmdline, "ls")) { cmd_ls(console); } else if(0 == strncmp(cmdline, "type ", 5)) { cmd_type(console, fat, cmdline); } //不是命令但也不是空行 else if(0 != cmdline[0]) { //运行那个应用程序的任务已经在cmd_app中执行了,返回值只是告诉这里是否正常运行了而已 if(0 == cmd_app(console, fat, cmdline)) { //如果到这里了,说明这个命令对应的既不是命令,又不是应用程序,而且不是空行 console_putstring_toend(console, "Bad Command!\n\n"); } } return ; }
//执行指定指令的函数 void console_runcmd(char *cmdline, CONSOLE *console, int *fat, unsigned int mem_total) { if(0 == strcmp(cmdline, "mem")) { cmd_mem(console, mem_total); } else if(0 == strcmp(cmdline, "clear")) { cmd_clear(console); } else if(0 == strcmp(cmdline, "ls")) { cmd_ls(console); } else if(0 == strncmp(cmdline, "type ", 5)) { cmd_type(console, fat, cmdline); } else if(0 == strcmp(cmdline, "hlt")) { cmd_hlt(console, fat); } //不是命令但也不是空行 else if(0 != cmdline[0]) { displayStrings_atLayer(console->layer, 8, console->cursor_y, COL8_FFFFFF, COL8_000000, "Bad command!"); console_newline(console); console_newline(console); } return ; }
void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, int memtotal) { if (strcmp(cmdline, "mem") == 0 && cons->sht != 0) { cmd_mem(cons, memtotal); } else if (strcmp(cmdline, "cls") == 0 && cons->sht != 0) { cmd_cls(cons); } else if (strcmp(cmdline, "dir") == 0 && cons->sht != 0) { cmd_dir(cons, cmdline); } else if (strcmp(cmdline, "task") == 0) { cmd_task(); } else if (strcmp(cmdline, "exit") == 0) { cmd_exit(cons, fat); } else if (strncmp(cmdline, "start ", 6) == 0) { cmd_start(cons, cmdline, memtotal); } else if (strncmp(cmdline, "ncst ", 5) == 0) { cmd_ncst(cons, cmdline, memtotal); } else if (strncmp(cmdline, "langmode ", 9) == 0) { cmd_langmode(cons, cmdline); } else if (strncmp(cmdline, "taskmgr", 7) == 0) { open_taskmgr(memtotal); } else if (cmdline[0] != 0) { if (cmd_app(cons, fat, cmdline) == 0) { /* Ŀ�ǵ嵵 �ƴϰ�, ���ø����̼ǵ� �ƴϰ�, �� �൵ �ƴϴ� */ cons_putstr0(cons, "Bad command or file name.\n\n"); } } return; }
void cons_runcmd (char *cmdline, struct CONSOLE *cons, int *fat, unsigned int memtotal) { if (strcmp(cmdline, "mem") == 0) { cmd_mem (cons, memtotal); } else if (strcmp(cmdline, "cls") == 0) { cmd_cls (cons); } else if (strcmp (cmdline, "dir") == 0) { cmd_dir (cons); } else if (cmdline[0]=='t' && cmdline[1]=='y' && cmdline[2]=='p' && cmdline[3]=='e' && cmdline[4]==' ') { cmd_type (cons, fat, cmdline); } else if (cmdline[0] != 0) { if (cmd_app(cons, fat, cmdline) == 0) { // Not Command Line and Empty cons_putstr0 (cons, "bad command.\n\n"); } } }
void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, unsigned int memtotal) { if (strcmp(cmdline, "mem") == 0) { cmd_mem(cons, memtotal); } else if (strcmp(cmdline, "cls") == 0) { cmd_cls(cons); } else if (strcmp(cmdline, "dir") == 0) { cmd_dir(cons); } else if (strncmp(cmdline, "type", 5) == 0) { cmd_type(cons, fat, cmdline); } else if (cmdline[0] != 0) { if (cmd_app(cons, fat, cmdline) == 0) { cons_putstr0(cons, "Bad command.\n\n"); } } return; }
void cons_runcmd (char *cmdline, struct CONSOLE *cons, int *fat, unsigned int memtotal) { if (strcmp(cmdline, "mem") == 0) { cmd_mem (cons, memtotal); } else if (strcmp(cmdline, "cls") == 0) { cmd_cls (cons); } else if (strcmp (cmdline, "dir") == 0) { cmd_dir (cons); } else if (cmdline[0]=='t' && cmdline[1]=='y' && cmdline[2]=='p' && cmdline[3]=='e' && cmdline[4]==' ') { cmd_type (cons, fat, cmdline); } else if (strcmp (cmdline, "hlt") == 0) { cmd_hlt (cons, fat); } else if (cmdline[0] != 0) { // Not Command Line and Empty putfonts8_asc_sht (cons->sht, 8, cons->cur_y, COL8_FFFFFF, COL8_000000, "Bad command.", 12); cons_newline (cons); cons_newline (cons); } }
void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, unsigned int memtotal) { if (strcmp(cmdline, "mem") == 0) { cmd_mem(cons, memtotal); } else if (strcmp(cmdline, "cls") == 0) { cmd_cls(cons); } else if (strcmp(cmdline, "dir") == 0) { cmd_dir(cons); } else if (strncmp(cmdline, "type ", 5) == 0) { cmd_type(cons, fat, cmdline); } else if (strcmp(cmdline, "hlt") == 0) { cmd_hlt(cons, fat); } else if (cmdline[0] != 0) { /* コマンドではなく、さらに空行でもない */ putfonts8_asc_sht(cons->sht, 8, cons->cur_y, COL8_FFFFFF, COL8_000000, "Bad command.", 12); cons_newline(cons); cons_newline(cons); } return; }
void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, unsigned int memtotal) { if (strcmp(cmdline, "mem") == 0) { cmd_mem(cons, memtotal); } else if (strcmp(cmdline, "clear") == 0) { cmd_cls(cons); } else if (strcmp(cmdline, "ls") == 0) { cmd_dir(cons); } else if (strncmp(cmdline, "cat ", 4) == 0) { cmd_type(cons, fat, cmdline); //} else if (strcmp(cmdline, "hlt") == 0) { // cmd_hlt(cons, fat); } else if (cmdline[0] != 0) { if(cmd_app(cons,fat,cmdline) == 0) { bps(cons->sht, 8, cons->cur_y, COL8_000084,COL8_FFFFFF, "Bad command.", 12); cons_newline(cons); cons_newline(cons); } } return; }
void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, unsigned int memtotal) { /* 执行命令 */ if (strcmp(cmdline, "mem") == 0) { /* mem命令 */ cmd_mem(cons, memtotal); } else if (strcmp(cmdline, "cls") == 0) { /* cls命令 */ cmd_cls(cons); } else if (strcmp(cmdline, "dir") == 0) { /* dir命令 */ cmd_dir(cons); } else if (strncmp(cmdline, "type ", 5) == 0) { /* type命令 */ cmd_type(cons, fat, cmdline); } else if (cmdline[0] != 0) { if (cmd_app(cons, fat, cmdline) == 0) { /* 不是命令,不是应用程序,也不是空行 */ cons_putstr0(cons, "Bad command.\n\n"); } } return; }
void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, int memtotal) { if (strcmp(cmdline, "mem") == 0 && cons->sht != 0) { cmd_mem(cons, memtotal); } else if (strcmp(cmdline, "cls") == 0 && cons->sht != 0) { cmd_cls(cons); } else if (strcmp(cmdline, "dir") == 0 && cons->sht != 0) { cmd_dir(cons); } else if (strncmp(cmdline, "type ", 5) == 0 && cons->sht != 0) { cmd_type(cons, fat, cmdline); } else if (strcmp(cmdline, "exit") == 0) { cmd_exit(cons, fat); } else if (strncmp(cmdline, "start ", 6) == 0) { cmd_start(cons, cmdline, memtotal); } else if (strncmp(cmdline, "ncst ", 5) == 0) { cmd_ncst(cons, cmdline, memtotal); } else if (cmdline[0] != 0) { if (cmd_app(cons, fat, cmdline) == 0) { /* コマンドではなく、アプリでもなく、さらに空行でもない */ cons_putstr0(cons, "Bad command.\n\n"); } } return; }
static void cmd_test_all(BaseSequentialStream *chp, int argc, char *argv[]){ chprintf(chp, " \n\nRunning thread function \n \n"); chThdSleepMilliseconds(1000); cmd_threads(chp, argc, argv); chprintf(chp, "\n\nRunning runtime test \n \n"); chThdSleepMilliseconds(1000); cmd_rt(chp, argc, argv); chprintf(chp, "\n\nRunning beep test"); chThdSleepMilliseconds(1000); cmd_beep(chp, argc, argv); chprintf(chp, "\n\nRunning memory test \n \n"); chThdSleepMilliseconds(1000); cmd_mem(chp, argc, argv); chprintf(chp, "\n\nRunning LED test \n \n"); chThdSleepMilliseconds(1000); cmd_led(chp, argc, argv); chprintf(chp, "\n\nRunning accelerometer test \n \n"); chThdSleepMilliseconds(1000); cmd_accel(chp, argc, argv); chprintf(chp, "\n\nRunning barometer test \n \n"); chThdSleepMilliseconds(1000); cmd_barotest(chp, argc, argv); chprintf(chp, "\n\nRunning pyro channel test \n \n"); chThdSleepMilliseconds(1000); cmd_pyro(chp, argc, argv); return; }
int exec_parsed(){ // Execs a parsed command line. int error=0,i,got=-1,n; // Now execute the command. if(parse_nwords!=0){ // Search for a matching known command. for(i=0;i<max_cmds;i++){ if(strcmp(con_cmds[i].name,parse_words[0])==0){ got=i; } } if(got>=0){ // Make sure that we have the correct number of arguments for a command. if(con_cmds[got].type=='C'){ if(parse_nwords!=con_cmds[got].max+1){ got=-2; } } // If we have a variable, deal with it here. else{ // No arguments means view the variable. if(parse_nwords==1){ view_variable(got); got=1000; } // One argument means set the variable. if(parse_nwords==2){ // Find the value to set the variable to. if(con_cmds[got].type=='F'){ // It's a FIXED variable. n=ftofix(atof(parse_words[1])); } if(con_cmds[got].type=='I'){ // It's an INT. n=atoi(parse_words[1]); } if(con_cmds[got].type=='S'){ // It's a string. internal_setstring(con_cmds[got].s_mirror,parse_words[1]); } else{ // Put the value within limits. if(n<con_cmds[got].min){n=con_cmds[got].min;} if(n>con_cmds[got].max){n=con_cmds[got].max;} // Set the mirror to the value. con_cmds[got].mirror=n; } } // If we don't have one or two arguments, then its an error. if(parse_nwords>2){ got=-2; } } } // Execute an actual command, or set a given variable. switch(got){ case -1: internal_error();break; case 0: cmd_clear();break; case 1: player_crosshair=n;break; case 2: player_crosshair_color=n;break; case 3: cmd_dir();break; case 4: cmd_disconnect();break; case 5: cmd_exec();break; case 6: player_floors=n;break; case 7: player_fov_degrees=fixtof(n);break; case 8: player_fps=n;break; case 9: player_gamma=n;cmd_gamma();break; case 10: player_gfx_mode=n;cmd_gfx_mode();break; case 11: cmd_gfx_modes();break; case 12: player_heightfix=n;break; case 13: player_invert=n;break; case 14: light_con=n;break; case 15: light_depth=fixtof(n);break; case 16: cmd_loopdemo();break; case 17: cmd_map();break; case 18: cmd_mapinfo();break; case 19: player_map_rotate=n;break; case 20: player_map=n;break; case 21: player_map_size=n;break; case 22: cmd_mem();break; case 23: internal_setstring(player_pic_con,parse_words[1]); cmd_pic_con();break; case 24: cmd_playdemo();break; case 25: cmd_pwad();break; case 26: cmd_quit();break; case 27: cmd_recdemo();break; case 28: player_r_grad=n;break; case 29: player_r_gun=n;break; case 30: cmd_stop();break; case 31: cmd_syntax();break; case 32: cmd_time();break; case 33: cmd_timerefresh();break; case 34: player_trace=1;break; case 35: cmd_viewpic();break; case 36: cmd_viewtex();break; case 37: player_vsync=n;break; case 38: cmd_wads();break; case 39: player_walls=n;break; case 40: player_windowsize=n;break; } } // Return the error value. DEBUG: Do we use this? return(error); }