From: Erik M. <er...@us...> - 2002-01-06 15:44:26
|
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv19353/src/blob Modified Files: debug.c Log Message: New "call" command by Christopher Hoover. Index: debug.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/debug.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- debug.c 2002/01/03 16:07:17 1.8 +++ debug.c 2002/01/06 15:44:23 1.9 @@ -440,6 +440,71 @@ static char bitchghelp[] = "bitchg address value {and|or|xor|set|clear}\n"; __commandlist(BitChange, "bitchg", bitchghelp ); +/********************************************************************* + * Call + * + * AUTHOR: Christopher Hoover <ch...@hp...> + * REVISED: + * + * Jumps to an arbitrary address. + * + */ +static int Call( int argc, char *argv[] ) +{ + int ret = 0; + u32 adr, a = 0, b = 0, c = 0, d = 0; + int (*called_fn)(u32, u32, u32, u32); + + if ( argc < 2 || argc > 6 ) ERR( -EINVAL ); + + ret = strtou32( argv[1], &adr ); + if ( ret < 0 ) ERR( -EINVAL ); + + if ( argc >= 3 ) { + ret = strtou32( argv[2], &a ); + if ( ret < 0 ) ERR( -EINVAL ); + } + if ( argc >= 4 ) { + ret = strtou32( argv[2], &b ); + if ( ret < 0 ) ERR( -EINVAL ); + } + if ( argc >= 5 ) { + ret = strtou32( argv[2], &c ); + if ( ret < 0 ) ERR( -EINVAL ); + } + if ( argc >= 6) { + ret = strtou32( argv[2], &d ); + if ( ret < 0 ) ERR( -EINVAL ); + } + + SerialOutputString("Calling function at 0x"); + SerialOutputHex(adr); + SerialOutputString(" ...\n"); + serial_flush_output(); + + called_fn = (int (*)(u32, u32, u32, u32))adr; + + ret = called_fn(a, b, c, d); + + SerialOutputString("\nReturn value: 0x"); + SerialOutputHex((u32)ret); + serial_write('\n'); + + ret = 0; + +DONE: + if ( ret != 0 ) { + perror( ret, __FUNCTION__ ); + } + return ret; +} + +static char callhelp[] = "call address [arg0 [arg1 [arg2 [arg3]]]]\n" +"Call function at <address> with optional arguments\n"; + +__commandlist(Call, "call", callhelp); + + /********************************************************************** * static functions */ |