X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=firmware%2Fapps%2Fmonitor%2Fmonitor.c;h=1263bcb007524c6c3094af5999d1c8523177f19e;hb=ce0bba3cfbf4844bdce1f6984af24d1f78c347f1;hp=defa814a63660b32089af08b539d13b57cede651;hpb=4323091949d787158fccc6871356bcdd61fffffa;p=goodfet diff --git a/firmware/apps/monitor/monitor.c b/firmware/apps/monitor/monitor.c index defa814..1263bcb 100644 --- a/firmware/apps/monitor/monitor.c +++ b/firmware/apps/monitor/monitor.c @@ -1,4 +1,13 @@ +/*! \file monitor.c + \author Travis Goodspeed + + This is an implementation of the SPI protocol + for the GoodFET project. +*/ + #include "command.h" +#include "platform.h" +#include "monitor.h" //! Handles a monitor command. void monitorhandle(unsigned char app, @@ -15,5 +24,53 @@ void monitorhandle(unsigned char app, cmddata[0]=memorybyte[cmddataword[0]]; txdata(app,verb,1); break; + case MONITOR_CHANGE_BAUD: + //This command, and ONLY this command, does not reply. + setbaud(cmddata[0]); + //txdata(app,verb,0); + break; + case MONITOR_RAM_PATTERN: + monitor_ram_pattern();//reboots, will never return + break; + case MONITOR_RAM_DEPTH: + cmddataword[0]=monitor_ram_depth(); + txdata(app,verb,2); + break; + case MONITOR_DIR: + P5DIR=cmddata[0]; + txdata(app,verb,1); + break; + case MONITOR_IN: + cmddata[0]=P5IN; + txdata(app,verb,1); + break; + case MONITOR_OUT: + P5OUT=cmddata[0]; + txdata(app,verb,1); + break; } } + +//! Overwrite all of RAM with 0xBEEF, then reboot. +void monitor_ram_pattern(){ + register int *a; + + //Wipe all of ram. + for(a=(int*)0x1100;a<(int*)0x2500;a++){//TODO get these from the linker. + *((int*)a) = 0xBEEF; + } + txdata(0x00,0x90,0); + + //Reboot + asm("br &0xfffe"); +} + +//! Return the number of contiguous bytes 0xBEEF, to measure RAM usage. +unsigned int monitor_ram_depth(){ + register int a; + register int count=0; + for(a=0x1100;a<0x2500;a+=2) + if(*((int*)a)==0xBEEF) count+=2; + + return count; +}