X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fapps%2Fmonitor%2Fmonitor.c;h=85c523f883cfc9e074899ca72d8dd4f04265b7b1;hp=3f35ea2e519138714a24700d03749546b0691a28;hb=f5edcbfc46dfafc434774a3e2849582be7cc6348;hpb=f4a6b415e762bcdc560f3ea655851d16f483ea5a;ds=sidebyside diff --git a/firmware/apps/monitor/monitor.c b/firmware/apps/monitor/monitor.c index 3f35ea2..85c523f 100644 --- a/firmware/apps/monitor/monitor.c +++ b/firmware/apps/monitor/monitor.c @@ -7,11 +7,21 @@ #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 long len){ switch(verb){ + default: + debugstr("ERROR: Command unsupported by debug monitor."); + break; case PEEK: cmddata[0]=memorybyte[cmddataword[0]]; txdata(app,verb,1); @@ -22,6 +32,16 @@ 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; @@ -69,7 +89,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.