📄 monitor_cmd.c
字号:
xprintf ("[skipping %s]\n", regtab[i].registername); } else { skipping_group = 0; xprintf ("[%s]\n", regtab[i].registername);#if 0 len = strlen (regtab[i].registername) + 2; while (len < MAXLINES) { xputchar (' '); len++; }#endif } } } else if (!skipping_group) { xsprintf(buf, "%4s: %s", regtab[i].registername, get_register_str (regtab[i].registernumber, 0)); buflen = strlen (buf); if ((buflen + len + 3) >= 80) { xprintf ("\n"); len = 0; } else if(len > 0) { xprintf (" "); len += 3; } xprintf (buf); len += buflen; } } if (len > 0) { xprintf ("\n"); }}static intgetregister (void){ int i; if (argvect[1] == 0) { display_group (-1); } else { for (i = 0; regtab[i].registername != NULL; i++) { if (!(strcmp (argvect[1], regtab[i].registername))) { break; } } if (regtab[i].registername == NULL) { xprintf ("No such register\n"); } else { if (regtab[i].registernumber < 0) { display_group (i); } else { xprintf("%s: %s\n", argvect[1], get_register_str (regtab[i].registernumber, 1)); } } } return 0;}static int setregister (void){ int number = -1; int i; if ((argvect[1] != 0) && (argvect[2] != 0)) { i = 0; while (regtab[i].registername != NULL) { if (!(strcmp (argvect[1], regtab[i].registername))) { number = regtab[i].registernumber; break; } i++; } if (number < 0) xprintf ("Unknown register name %s\n", argvect[1]); else store_register (number, argvect[2]); } else { xprintf ("Not enough arguments\n"); } return 0;}intreg_cmd (cmdmode_t mode){ if (mode == USAGE) { usage ("register [register name] [value]"); return 0; } if (mode == SHORT_HELP) { short_help ("View and manipulate registers"); return 0; } if (mode == LONG_HELP) { reg_cmd (USAGE); long_help ("\The register command allows the viewing and manipulation of register\n\contents. It can take zero, one, or two arguments. When called with zero\n\arguments, the register command displays the values of all registers. When\n\called with only the register name argument, it displays the contents of\n\the specified register. When called with both a register name and a value,\n\it places that value into the specified register.\n"); example ("\register " REGNAME_EXAMPLE " 1f\n\Places the value 1f in the register " REGNAME_EXAMPLE); return 0; } if (argvect[1] != NULL && argvect[2] != NULL) { if (argvect[3] != NULL) { return reg_cmd (USAGE); } return setregister (); } else return getregister ();}/* execute the program in memory */int go_cmd (cmdmode_t mode){#ifdef HAS_TIMER extern tick_type start_tickcount;#endif if (mode == USAGE) { usage ("go [location]"); return 0; } if (mode == SHORT_HELP) { short_help ("Start user program execution"); return 0; } if (mode == LONG_HELP) { go_cmd (USAGE); long_help ("\The go command starts user program execution. It can take zero or one\n\argument. If no argument is provided, go starts execution at the current\n\pc. If an argument is specified, go sets the pc to that location, and then\n\starts execution at that location.\n"); example ("go 40020000\n\Sets the pc to 40020000, and starts program execution."); return 0; } if (argvect[1] != NULL && argvect[2] != NULL) { return go_cmd (USAGE); } if (argvect[1] != NULL) { set_pc (str2int (argvect[1], 16)); }#ifdef HAS_TIMER start_tickcount = __read_ticks ();#endif /* We want monitor_loop to exit now. */ return 1;}#ifdef HAS_TIMERinttimer_cmd (cmdmode_t mode){ if (mode == USAGE) { usage ("timer [state]"); return 0; } if (mode == SHORT_HELP) { short_help ("Enable and disable timer"); return 0; } if (mode == LONG_HELP) { timer_cmd (USAGE); long_help ("\The timer command allows control of the on board timer. It takes zero\n\or one argument. With zero arguments, it displays the state of the timer,\n\with one argument, which can start with e or d, it enables or disables the\n\timer, respectively.\n"); example ("\timer e\n\Enables the timer."); return 0; } if (argvect[1] != NULL) { if (argvect[2] != NULL) { return timer_cmd (USAGE); } else if (argvect[1][0] == 'e') { __settimer (0, 0); } else if (argvect[1][0] == 'd') { __disable_timer (); } else { timer_cmd (USAGE); } } if (__timer_enabled ()) { xprintf ("Timer is currently enabled.\n"); } else { xprintf ("Timer is currently disabled.\n"); } return 0;}#endifint clear_breakpoint_cmd (cmdmode_t mode){ if (mode == USAGE) { usage ("unbreak location"); return 0; } if (mode == SHORT_HELP) { short_help ("Clear breakpoint"); return 0; } if (mode == LONG_HELP) { clear_breakpoint_cmd (USAGE); long_help ("\The unbreak command removes breakpoints from memory. It takes one\n\argument, the location to remove the breakpoint from.\n"); example ("\unbreak 4ff5\n\Removes a previously set breakpoint at memory location 4ff5."); return 0; } if (argvect[1] == NULL || argvect[2] != NULL) { clear_breakpoint_cmd (USAGE); } else { mem_addr_t location; str2addr (argvect[1], &location); clear_mon_breakpoint (location); } return 0;}intbreakpoint_cmd (cmdmode_t mode){ if (mode == USAGE) { usage ("break [location]"); return 0; } if (mode == SHORT_HELP) { short_help ("Set or display breakpoints"); return 0; } if (mode == LONG_HELP) { breakpoint_cmd (USAGE); long_help ("\The break command displays and sets breakpoints in memory. It takes zero\n\or one argument. With zero arguments, it displays a list of all currently\n\set breakpoints. With one argument it sets a new breakpoint at the\n\specified location.\n"); example ("\break 4ff5\n\Sets a breakpoint at address 4ff5."); return 0; } if (argvect[1] == NULL) { return show_breakpoints (); } else if (argvect[2] != NULL) { breakpoint_cmd (USAGE); } else { mem_addr_t location; str2addr (argvect[1], &location); add_mon_breakpoint (location); } return 0;}intversion_cmd (cmdmode_t mode){ if (mode == USAGE) { usage ("version"); return 0; } if (mode == SHORT_HELP) { short_help ("Display version"); return 0; } if (mode == LONG_HELP) { version_cmd (USAGE); long_help ("\The version command displays the version of the monitor."); return 0; } if (argvect[1] == NULL) { version (); } else { version_cmd (USAGE); } return 0;}intset_serial_port_cmd (cmdmode_t mode){ if (mode == USAGE) { usage ("port [port number]"); return 0; } if (mode == SHORT_HELP) { short_help ("Set the active serial port"); return 0; } if (mode == LONG_HELP) { set_serial_port_cmd (USAGE); long_help ("\The port command allows control over the serial port being used by the\n\monitor. It takes zero or one argument. Called with zero arguments it\n\displays the port currently in use by the monitor. Called with one\n\argument it switches the port in use by the monitor to the one specified.\n\It then prints out a message on the new port to confirm the switch.\n"); example ("\port 1\n\Switches the port in use by the monitor to port 1."); return 0; } if (argvect[1] != NULL && argvect[2] != NULL) { set_serial_port_cmd (USAGE); return 0; } if (argvect [1] != NULL) {#ifdef HAVE_BSP if (bsp_set_debug_comm(str2int (argvect[1], 10)) < 0) xprintf("Invalid port number.\n"); else /* Since we are using the new port, we just need to write something to tell the user that this is the active port */ xprintf ("Cygmon I/O now on this port.\n");#else __setTty (str2int (argvect[1], 10)); /* Since we are using the new port, we just need to write something to tell the user that this is the active port */ xprintf ("Cygmon I/O now on this port.\n");#endif } else { xprintf ("serial port currently set to %d\n", __getTty()); return 0; } return 0;}int step_cmd (cmdmode_t mode){ if (mode == USAGE) { usage ("step [location]"); return 0; } if (mode == SHORT_HELP) { short_help ("Single step user program"); return 0; } if (mode == LONG_HELP) { step_cmd (USAGE); long_help ("\The step command causes one instruction of the user program to execute, then\n\returns control to the monitor. It can take zero or one argument. If no\n\argument is provided, step executes one instruction at the current pc. If\n\a location is specified, step executes one instruction at the specified\n\location.\n"); example ("step\n\Executes one instruction at the current pc."); return 0; } if (argvect[1] != NULL && argvect[2] != NULL) { step_cmd (USAGE); return 0; } if (argvect[1] != NULL) set_pc (str2int (argvect[1], 16)); __single_step (); return 1;}#if HAVE_CACHE/* This cache function needs to be in processor-specific files. */intcache_cmd (cmdmode_t mode){ int x; int cache_op = CACHE_NOOP; int which_cache = -1; if (mode == USAGE) { usage ("cache [type] [state]"); return 0; } if (mode == SHORT_HELP) { short_help ("Manipulate caches"); return 0; } if (mode == LONG_HELP) { cache_cmd (USAGE); long_help ("\The cache command displays and changes the states of the caches. It takes\n\zero, one, or two arguments. With no arguments, it displays the state of\n\both the instruction cache and the data cache. With one argument, it\n\displays the state of the specified type of cache. With two arguments, it\n\changes the state of the specified cache to the specified state.\n"); example ("\cache i d\n\Disables the instruction cache."); return 0; } if (argvect[1] != NULL && argvect[2] != NULL && argvect[3] != NULL) { return cache_cmd (USAGE); } if (argvect[1] != NULL) { if (argvect[1][0] == 'd') which_cache = 0; else if (argvect[1][0] == 'i') which_cache = 1; else { xprintf ("unknown cache type %s\n", argvect[1]); return 0; } if (argvect[2] != NULL) { if (argvect[2][0] == 'e') cache_op = CACHE_ENABLE; else if (argvect[2][0] == 'd') cache_op = CACHE_DISABLE; else if (argvect[2][0] == 'f') cache_op = CACHE_FLUSH; else { xprintf ("Unknown cache op %s\n", argvect[2]); return 0; } } } if (which_cache == 0 || which_cache == -1) { __data_cache (cache_op); if (cache_op == CACHE_FLUSH) { xprintf ("Flushed dcache\n"); } x = __data_cache (CACHE_NOOP); xprintf ("dcache is "); xprintf (x ? "enabled\n" : "disabled\n"); } if (which_cache == 1 || which_cache == -1) { __instruction_cache (cache_op); if (cache_op == CACHE_FLUSH) { xprintf ("Flushed icache\n"); } x = __instruction_cache (CACHE_NOOP); xprintf ("icache is "); xprintf (x ? "enabled\n" : "disabled\n"); } return 0;}#endifintset_serial_speed_cmd (cmdmode_t mode){ if (mode == USAGE) { usage ("baud speed"); return 0; } if (mode == SHORT_HELP) { short_help ("Set serial port baud rate"); return 0; } if (mode == LONG_HELP) { set_serial_speed_cmd (USAGE); long_help ("\The baud command sets the speed of the active serial port. It takes one\n\argument, which specifies the speed to which the port will be set.\n"); example ("\baud 9600\n\Sets the speed of the active port to 9600 baud."); return 0; } if (argvect[1] == NULL || argvect[2] != NULL) { return set_serial_speed_cmd (USAGE); } else {#ifdef HAVE_BSP int channel_id = bsp_set_debug_comm(-1); int baud = str2int (argvect[1], 10); xprintf("Setting serial baud rate on channel %d to %d baud\n", channel_id, baud); if (bsp_set_serial_baud(bsp_set_debug_comm(-1), str2int (argvect[1], 10)) < 0) xprintf("Invalid baud rate\n");#else __set_baud_rate (str2int (argvect[1], 10));#endif } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -