From 4de4683d6ed9abb3ce6eea37957f845d6d33243f Mon Sep 17 00:00:00 2001 From: travisutk Date: Thu, 7 Jan 2010 13:23:07 +0000 Subject: [PATCH] Rough draft of CALL/EXEC support for the Monitor. Nice and neighborly, for quickly patching in new code. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@260 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- firmware/apps/monitor/monitor.c | 17 +++++++++++++++++ firmware/include/command.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/firmware/apps/monitor/monitor.c b/firmware/apps/monitor/monitor.c index 3f35ea2..33b31c7 100644 --- a/firmware/apps/monitor/monitor.c +++ b/firmware/apps/monitor/monitor.c @@ -7,6 +7,13 @@ #include "platform.h" #include "monitor.h" +//! Call a function by address. +int fncall(unsigned int adr){ + //TODO replace this with portable C. + //Preprocessor definition might help. + __asm__("call r15"); //r12 on IAR +} + //! Handles a monitor command. void monitorhandle(unsigned char app, unsigned char verb, @@ -22,6 +29,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; diff --git a/firmware/include/command.h b/firmware/include/command.h index 6f94d6b..7ec0f1c 100644 --- a/firmware/include/command.h +++ b/firmware/include/command.h @@ -41,6 +41,8 @@ extern unsigned char silent; #define SETUP 0x10 #define START 0x20 #define STOP 0x21 +#define CALL 0x30 +#define EXEC 0x31 #define NOK 0x7E #define OK 0x7F -- 2.20.1