00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00028 #ifndef _CMDLINE_H_
00029 #define _CMDLINE_H_
00030
00031 #include <vector>
00032
00034 class Command {
00035 public:
00037 virtual char *getName()=0;
00038
00040 virtual char *getBrief()=0;
00041
00043 virtual char *getDescr()=0;
00044
00046 virtual int exec(int argc, char *argv[])=0;
00047 };
00048
00050 class CmdLine {
00051 private:
00052 std::vector<Command *> commands;
00053
00054 public:
00055 CmdLine();
00056 virtual ~CmdLine();
00057
00059 int exec(const char *cmdLine, int argc=0, char **argv=0);
00060
00061 static int getEndOfToken(const char *string, const char *delim);
00062
00066 static int getNextToken(const char *string, const char *delim);
00067
00069 static int splitString(char *inputString, char **outputArray,
00070 unsigned arraySize, const char *delimiters);
00071 };
00072
00074 class LoadICCmd : public Command {
00075 public:
00076 virtual char *getName() { return "loadic"; }
00077 virtual char *getBrief() { return "load a file in the instruction cache"; }
00078 virtual char *getDescr();
00079 virtual int exec(int argc, char *argv[]);
00080 };
00081
00083 class CheckCmd : public Command {
00084 public:
00085 virtual char *getName() { return "check"; }
00086 virtual char *getBrief() { return "check connection with PXA250." ; }
00087 virtual char *getDescr() { return "check connection with PXA250 and print out some information.\n" ; }
00088 virtual int exec(int argc, char *argv[]);
00089 };
00090
00092 class InitCmd : public Command {
00093 public:
00094 virtual char *getName() { return "init"; }
00095 virtual char *getBrief() { return "init JTAG connection with the EzUSB microcontroller." ; }
00096 virtual char *getDescr() { return "init connection with the EzUSB microcontroller.\n" \
00097 "Availables options :\n" \
00098 "\tv / idvendor [vendor ID]\n"\
00099 "\tp / idproduct [product ID]\n"\
00100 "\tf / filename [EzUSB firmeware filename]\n" ; }
00101 virtual int exec(int argc, char *argv[]);
00102 };
00103
00107 class StopCmd : public Command {
00108 public:
00109 virtual char *getName() { return "stop"; }
00110 virtual char *getBrief() { return "stop CPU execution"; }
00111 virtual char *getDescr() { return "Stop CPU execution and force it to stay in internal reset mode, ready for code upload\n"; }
00112 virtual int exec(int argc, char *argv[]);
00113 };
00114
00116 class BootCmd : public Command {
00117 public:
00118 virtual char *getName() { return "boot"; }
00119 virtual char *getBrief() { return "boot the CPU"; }
00120 virtual char *getDescr() { return "start program execution from reset vector (usualy 0x00000000)\n"; }
00121 virtual int exec(int argc, char *argv[]);
00122 };
00123
00125 class ResetCmd : public Command {
00126 public:
00127 virtual char *getName() { return "reset"; }
00128 virtual char *getBrief() { return "reset the JTAG interface"; }
00129 virtual char *getDescr() { return "put the JTAG unit of the PXA250 in the run test/idle state\n"; }
00130 virtual int exec(int argc, char *argv[]);
00131 };
00132
00134 class QuitCmd : public Command {
00135 public:
00136 virtual char *getName() { return "quit"; }
00137 virtual char *getBrief() { return "quit this program"; }
00138 virtual char *getDescr() { return "terminate the execution of this program.\n"; }
00139 virtual int exec(int argc, char *argv[]);
00140 };
00141
00143 class PutCmd : public Command {
00144 public:
00145 virtual char *getName() { return "put"; }
00146 virtual char *getBrief() { return "put data in the device memory"; }
00147 virtual char *getDescr() { return "put <address> <value> [h]\n"
00148 "If the 3rd parameter 'h' is ommited, write the 32 bits word\n"
00149 "<value> at address <address>. If 'h' is present, write only 16 bits\n"; }
00150 virtual int exec(int argc, char *argv[]);
00151 };
00152
00154 class GetCmd : public Command {
00155 public:
00156 virtual char *getName() { return "get"; }
00157 virtual char *getBrief() { return "get data from the device memory"; }
00158 virtual char *getDescr() { return "get <address> [size in number of word of data]\
00159 \nIf size is ommited, it is assumed to be 1."; }
00160 virtual int exec(int argc, char *argv[]);
00161 };
00162
00164 class LoadCmd : public Command {
00165 public:
00166 virtual char *getName() { return "load"; }
00167 virtual char *getBrief() { return "load a binary into the device's memory"; }
00168 virtual char *getDescr() { return "load <filename> [address [h]]\
00169 \nIf address is ommited, it is assumed to be 0xa0000000. If h is present,\n"
00170 "the write will be made in 16 bits words.\n"; }
00171 virtual int exec(int argc, char *argv[]);
00172 };
00173
00175 class ProgramFlashCmd : public Command {
00176 private:
00177 CmdLine cmdLine;
00178 public:
00179 ProgramFlashCmd(CmdLine &cmdLine);
00180 virtual char *getName() { return "program"; }
00181 virtual char *getBrief() { return "program a binary into the device's flash memory"; }
00182 virtual char *getDescr() { return "program <filename> [address]\
00183 \nIf address is ommited, it is assumed to be 0x00000000. Sectors are erased before.\n"
00184 "partially programmed sectors are ok: old data is reflashed.\n"; }
00185 virtual int exec(int argc, char *argv[]);
00186 };
00187
00189 class ExecCmd : public Command {
00190 public:
00191 virtual char *getName() { return "exec"; }
00192 virtual char *getBrief() { return "exec a program from the device's memory"; }
00193 virtual char *getDescr() { return "exec [start address] [stack pointer address]\
00194 \nIf start addres is ommited, it is assumed to be 0xa0000000 \
00195 \nIf stack pointer addres is ommited, it is assumed to be 0xa2000000"; }
00196 virtual int exec(int argc, char *argv[]);
00197 };
00198
00200 class EraseFlashCmd: public Command
00201 {
00202 public:
00203 virtual char *getName() { return "erase"; }
00204 virtual char *getBrief() { return "erase a sector or the whole flash"; }
00205 virtual char *getDescr() { return "erase [sector address] ... [sector address]\
00206 \nIf not sector is given, a whole flash erase if performed"; }
00207 virtual int exec(int argc, char *argv[]);
00208 };
00209
00211 class HelpCmd: public Command {
00212 private:
00213 std::vector<Command *> & cmds;
00214
00215 public:
00216 HelpCmd(std::vector<Command *> & cmds) : cmds(cmds) {}
00217 virtual char *getName() { return "help"; }
00218 virtual char *getBrief() { return "list all commands or gives help about a command"; }
00219 virtual char *getDescr() { return "help without argument lists all commands.\n"
00220 "Help <cmd> gives details about a precise command\n"; }
00221 virtual int exec(int argc, char *argv[]);
00222 };
00223
00225 class ExtBreakCmd : public Command {
00226 public:
00227 virtual char *getName() { return "extbreak"; }
00228 virtual char *getBrief() { return "sends an external break event to the processor"; }
00229 virtual char *getDescr() { return "extbreak\
00230 \nThe program currently running is stoped, and a debug handling routine is called.\n"; }
00231 virtual int exec(int argc, char *argv[]);
00232 };
00233
00235 class RebootCmd : public Command {
00236 public:
00237 virtual char *getName() { return "reboot"; }
00238 virtual char *getBrief() { return "reboot the CPU"; }
00239 virtual char *getDescr() { return "reboot\
00240 \nReboot the CPU, exactly like pressing the reset button on the PXA board.\n"; }
00241 virtual int exec(int argc, char *argv[]);
00242 };
00243
00245 class ContinueCmd : public Command {
00246 public:
00247 virtual char *getName() { return "continue"; }
00248 virtual char *getBrief() { return "continue the execution of a program"; }
00249 virtual char *getDescr() { return "continue\
00250 \nAfter a breakpoint or an external break, continues the execution of the debugged program.\n"; }
00251 virtual int exec(int argc, char *argv[]);
00252 };
00253
00255 class RegisterCmd : public Command {
00256 public:
00257 virtual char *getName() { return "register"; }
00258 virtual char *getBrief() { return "read or write a register"; }
00259 virtual char *getDescr() { return "register <reg> [<hex value>]\
00260 \nif only one parameter is given, this command will display the content of a register.\n"
00261 "if a value is given, it will be writen to the register.\n"; }
00262 virtual int exec(int argc, char *argv[]);
00263 };
00264
00266 class HwBreakCmd : public Command {
00267 public:
00268 virtual char *getName() { return "hwbreak"; }
00269 virtual char *getBrief() { return "control the hardware breakpoints"; }
00270 virtual char *getDescr() { return "hwbreak on|off [<address>] [0|1]\
00271 \nset or remove a hardware breakpoint. If the address is omitted, PC + 4 will be used.\n"
00272 "the last parameter allow to switch between hardware breakpoint 0 and 1.\n"; }
00273 virtual int exec(int argc, char *argv[]);
00274 };
00275
00277 class WaitCmd: public Command {
00278 public:
00279 virtual char *getName() { return "wait"; }
00280 virtual char *getBrief() { return "wait for the debug handler"; }
00281 virtual char *getDescr() { return "wait until the debug handler is ready"
00282 "to execute more commands."; }
00283 virtual int exec(int argc, char *argv[]);
00284 };
00285
00286 #endif
00287