📄 cmdline.h
字号:
/* * This file is part of Jelie, * (c) 2002 Julien Pilet <julien.pilet@epfl.ch> and * Stephane Magnenat <stephane.magnenat@epfl.ch> * * Jelie is free software; you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * Jelie is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Foobar; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *//*! \file * \brief Command line declarations * * \author Julien Pilet <julien.pilet@epfl.ch> * \author Stephane Magnenat <stephane.magnenat@epfl.ch> */#ifndef _CMDLINE_H_#define _CMDLINE_H_#include <vector>//! abstract class for commands in the command line.class Command {public: //! the name of the command that will be compared with user input. virtual char *getName()=0; //! a brief description of the command (1 line) virtual char *getBrief()=0; //! a long help about the command virtual char *getDescr()=0; //! execute the command with the some arguments. virtual int exec(int argc, char *argv[])=0;};//! the command line itself. Basically executes command from user input.class CmdLine {private: std::vector<Command *> commands;public: CmdLine(); virtual ~CmdLine(); //! execute a command line. int exec(const char *cmdLine, int argc=0, char **argv=0); static int getEndOfToken(const char *string, const char *delim); /*! return the index of the next character which is not in "delim", or * -1 if not found. */ static int getNextToken(const char *string, const char *delim); //! split a string into an array of words static int splitString(char *inputString, char **outputArray, unsigned arraySize, const char *delimiters);};//! command class for loading instructions in cache.class LoadICCmd : public Command {public: virtual char *getName() { return "loadic"; } virtual char *getBrief() { return "load a file in the instruction cache"; } virtual char *getDescr(); virtual int exec(int argc, char *argv[]);};//! command class for checing the connection with the PXA250class CheckCmd : public Command {public: virtual char *getName() { return "check"; } virtual char *getBrief() { return "check connection with PXA250." ; } virtual char *getDescr() { return "check connection with PXA250 and print out some information.\n" ; } virtual int exec(int argc, char *argv[]);};//! command class for initializing the USB connection device.class InitCmd : public Command {public: virtual char *getName() { return "init"; } virtual char *getBrief() { return "init JTAG connection with the EzUSB microcontroller." ; } virtual char *getDescr() { return "init connection with the EzUSB microcontroller.\n" \ "Availables options :\n" \ "\tv / idvendor [vendor ID]\n"\ "\tp / idproduct [product ID]\n"\ "\tf / filename [EzUSB firmeware filename]\n" ; } virtual int exec(int argc, char *argv[]);};/*! command class for stopping the CPU execution and put it in internal reset * state */class StopCmd : public Command {public: virtual char *getName() { return "stop"; } virtual char *getBrief() { return "stop CPU execution"; } virtual char *getDescr() { return "Stop CPU execution and force it to stay in internal reset mode, ready for code upload\n"; } virtual int exec(int argc, char *argv[]);};//! command class for booting the CPU.class BootCmd : public Command {public: virtual char *getName() { return "boot"; } virtual char *getBrief() { return "boot the CPU"; } virtual char *getDescr() { return "start program execution from reset vector (usualy 0x00000000)\n"; } virtual int exec(int argc, char *argv[]);};//! command class to put the JTAG state machine in run test/idle state.class ResetCmd : public Command {public: virtual char *getName() { return "reset"; } virtual char *getBrief() { return "reset the JTAG interface"; } virtual char *getDescr() { return "put the JTAG unit of the PXA250 in the run test/idle state\n"; } virtual int exec(int argc, char *argv[]);};//! command class to quit the program.class QuitCmd : public Command {public: virtual char *getName() { return "quit"; } virtual char *getBrief() { return "quit this program"; } virtual char *getDescr() { return "terminate the execution of this program.\n"; } virtual int exec(int argc, char *argv[]);};//! command class to put data into memoryclass PutCmd : public Command {public: virtual char *getName() { return "put"; } virtual char *getBrief() { return "put data in the device memory"; } virtual char *getDescr() { return "put <address> <value> [h]\n" "If the 3rd parameter 'h' is ommited, write the 32 bits word\n" "<value> at address <address>. If 'h' is present, write only 16 bits\n"; } virtual int exec(int argc, char *argv[]);};//! command class to put data into memoryclass GetCmd : public Command {public: virtual char *getName() { return "get"; } virtual char *getBrief() { return "get data from the device memory"; } virtual char *getDescr() { return "get <address> [size in number of word of data]\ \nIf size is ommited, it is assumed to be 1."; } virtual int exec(int argc, char *argv[]);};//! command class to load data into the device memoryclass LoadCmd : public Command {public: virtual char *getName() { return "load"; } virtual char *getBrief() { return "load a binary into the device's memory"; } virtual char *getDescr() { return "load <filename> [address [h]]\ \nIf address is ommited, it is assumed to be 0xa0000000. If h is present,\n" "the write will be made in 16 bits words.\n"; } virtual int exec(int argc, char *argv[]);};//! command class to load data into the device's flash memoryclass ProgramFlashCmd : public Command {private: CmdLine cmdLine;public: ProgramFlashCmd(CmdLine &cmdLine); virtual char *getName() { return "program"; } virtual char *getBrief() { return "program a binary into the device's flash memory"; } virtual char *getDescr() { return "program <filename> [address]\ \nIf address is ommited, it is assumed to be 0x00000000. Sectors are erased before.\n" "partially programmed sectors are ok: old data is reflashed.\n"; } virtual int exec(int argc, char *argv[]);};//! command class to exec a program from the device memoryclass ExecCmd : public Command {public: virtual char *getName() { return "exec"; } virtual char *getBrief() { return "exec a program from the device's memory"; } virtual char *getDescr() { return "exec [start address] [stack pointer address]\ \nIf start addres is ommited, it is assumed to be 0xa0000000 \ \nIf stack pointer addres is ommited, it is assumed to be 0xa2000000"; } virtual int exec(int argc, char *argv[]);};//! command class to erase flashclass EraseFlashCmd: public Command{public: virtual char *getName() { return "erase"; } virtual char *getBrief() { return "erase a sector or the whole flash"; } virtual char *getDescr() { return "erase [sector address] ... [sector address]\ \nIf not sector is given, a whole flash erase if performed"; } virtual int exec(int argc, char *argv[]);};//! command class to provide help about available commands.class HelpCmd: public Command {private: std::vector<Command *> & cmds;public: HelpCmd(std::vector<Command *> & cmds) : cmds(cmds) {} virtual char *getName() { return "help"; } virtual char *getBrief() { return "list all commands or gives help about a command"; } virtual char *getDescr() { return "help without argument lists all commands.\n" "Help <cmd> gives details about a precise command\n"; } virtual int exec(int argc, char *argv[]);};//! command class to do external debug event (stop the execution of a program)class ExtBreakCmd : public Command {public: virtual char *getName() { return "extbreak"; } virtual char *getBrief() { return "sends an external break event to the processor"; } virtual char *getDescr() { return "extbreak\ \nThe program currently running is stoped, and a debug handling routine is called.\n"; } virtual int exec(int argc, char *argv[]);};//! command class to do a normal CPU reset.class RebootCmd : public Command {public: virtual char *getName() { return "reboot"; } virtual char *getBrief() { return "reboot the CPU"; } virtual char *getDescr() { return "reboot\ \nReboot the CPU, exactly like pressing the reset button on the PXA board.\n"; } virtual int exec(int argc, char *argv[]);};//! command class to do a normal CPU reset.class ContinueCmd : public Command {public: virtual char *getName() { return "continue"; } virtual char *getBrief() { return "continue the execution of a program"; } virtual char *getDescr() { return "continue\ \nAfter a breakpoint or an external break, continues the execution of the debugged program.\n"; } virtual int exec(int argc, char *argv[]);};//! command class to access registersclass RegisterCmd : public Command {public: virtual char *getName() { return "register"; } virtual char *getBrief() { return "read or write a register"; } virtual char *getDescr() { return "register <reg> [<hex value>]\ \nif only one parameter is given, this command will display the content of a register.\n" "if a value is given, it will be writen to the register.\n"; } virtual int exec(int argc, char *argv[]);};//! command class to control hardware breakpointsclass HwBreakCmd : public Command {public: virtual char *getName() { return "hwbreak"; } virtual char *getBrief() { return "control the hardware breakpoints"; } virtual char *getDescr() { return "hwbreak on|off [<address>] [0|1]\ \nset or remove a hardware breakpoint. If the address is omitted, PC + 4 will be used.\n" "the last parameter allow to switch between hardware breakpoint 0 and 1.\n"; } virtual int exec(int argc, char *argv[]);};//! command class to provide a way of waiting for the debug handler to be ready.class WaitCmd: public Command {public: virtual char *getName() { return "wait"; } virtual char *getBrief() { return "wait for the debug handler"; } virtual char *getDescr() { return "wait until the debug handler is ready" "to execute more commands."; } virtual int exec(int argc, char *argv[]);};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -