X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fapps%2Fmonitor%2Fmonitor.c;h=218afca6efa799a1db5935932575fe0b4b98bdcb;hp=1263bcb007524c6c3094af5999d1c8523177f19e;hb=5c029aa0c4f7573d9fa49beefe6e887dee2b25f9;hpb=ce0bba3cfbf4844bdce1f6984af24d1f78c347f1 diff --git a/firmware/apps/monitor/monitor.c b/firmware/apps/monitor/monitor.c index 1263bcb..218afca 100644 --- a/firmware/apps/monitor/monitor.c +++ b/firmware/apps/monitor/monitor.c @@ -1,19 +1,31 @@ /*! \file monitor.c \author Travis Goodspeed - - This is an implementation of the SPI protocol - for the GoodFET project. + \brief Local debug monitor. */ #include "command.h" #include "platform.h" #include "monitor.h" +//! Call a function by address. +int fncall(unsigned int adr){ + int (*machfn)() = 0; + machfn= (int (*)()) adr; + return machfn(); +} + //! Handles a monitor command. void monitorhandle(unsigned char app, unsigned char verb, - unsigned char len){ + unsigned long len){ switch(verb){ + default: + debugstr("ERROR: Command unsupported by debug monitor."); + break; + case MONITOR_ECHO: + //Echo back the same buffer. + txdata(app,verb,len); + break; case PEEK: cmddata[0]=memorybyte[cmddataword[0]]; txdata(app,verb,1); @@ -24,6 +36,21 @@ void monitorhandle(unsigned char app, cmddata[0]=memorybyte[cmddataword[0]]; txdata(app,verb,1); break; + case CALL: + //Set the program counter to cmdword[0]; + cmddataword[0]=fncall(cmddataword[0]); + txdata(app,verb,2); + break; + case EXEC: + //Execute the argument as code from RAM. + cmddataword[0]=fncall((u16) cmddataword); + txdata(app,verb,2); + break; + case MONITOR_SIZEBUF: + //TODO make the data length target-specific, varying by ram. + cmddataword[0]=0x100; + txdata(app,verb,2); + break; case MONITOR_CHANGE_BAUD: //This command, and ONLY this command, does not reply. setbaud(cmddata[0]); @@ -48,6 +75,14 @@ void monitorhandle(unsigned char app, P5OUT=cmddata[0]; txdata(app,verb,1); break; + case MONITOR_SILENT: + silent=cmddata[0]; + txdata(app,verb,1); + break; + case MONITOR_CONNECTED: + msp430_init_dco_done(); + txdata(app,verb,0); + break; } } @@ -62,7 +97,9 @@ void monitor_ram_pattern(){ txdata(0x00,0x90,0); //Reboot + #ifdef MSP430 asm("br &0xfffe"); + #endif } //! Return the number of contiguous bytes 0xBEEF, to measure RAM usage.