Update of /cvsroot/blob/blob/src/commands In directory usw-pr-cvs1:/tmp/cvs-serv28118 Modified Files: Makefile.am call.c changebit.c dummy.c dump.c memcpy.c peek.c poke.c Added Files: make_commands.sh Removed Files: cmddebug.h common.c common.h Log Message: Cleanup commands. Add a shell script to generate C code for commands. --- NEW FILE: make_commands.sh --- #! /bin/sh # # make_commands.sh: generate commandlist code # # Copyright (C) 2002 Erik Mouw (J.A...@it...) # # $Id: make_commands.sh,v 1.1 2002/02/17 20:01:31 erikm Exp $ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA cat <<EOF /* * WARNING: * This file was generated by make_commands.sh. All changes to this file * will be automatically overwritten once you rerun make_commands.sh. Do * not try to check this file into CVS: generated files do not belong in * CVS repositories. */ #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/command.h> EOF for i in $* ; do cat <<EOF extern int ${i}_cmd(int argc, char *argv[]); extern char ${i}_help[]; __commandlist(${i}_cmd, "${i}", ${i}_help); EOF done Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/commands/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.am 12 Feb 2002 12:54:59 -0000 1.2 +++ Makefile.am 17 Feb 2002 20:01:31 -0000 1.3 @@ -26,20 +26,24 @@ libcommands_a_SOURCES = \ - common.c \ - poke.c \ - peek.c \ - regs-sa11x0.c \ call.c \ changebit.c \ + dummy.c \ dump.c \ - chkmem.c \ - dummy.c + memcpy.c \ + peek.c \ + poke.c \ + reboot.c \ + terminal.c INCLUDES += \ -I${top_builddir}/include \ -I${top_srcdir}/include + + +EXTRA_DIST = \ + make_commands.sh CLEANFILES = ${srcdir}/*~ Index: call.c =================================================================== RCS file: /cvsroot/blob/blob/src/commands/call.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- call.c 12 Feb 2002 12:54:59 -0000 1.1 +++ call.c 17 Feb 2002 20:01:31 -0000 1.2 @@ -1,7 +1,6 @@ /* * debug.c: Debugging command functions * - * Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...> * Copyright (C) 2001 Christopher Hoover <ch...@hp...> * * This program is free software; you can redistribute it and/or modify @@ -31,14 +30,10 @@ #endif #include <blob/errno.h> -#include <blob/error.h> +#include <blob/debug.h> +#include <blob/serial.h> #include <blob/types.h> #include <blob/util.h> -#include <blob/serial.h> -#include <blob/command.h> - -#include "cmddebug.h" -#include "common.h" /********************************************************************** @@ -48,16 +43,6 @@ /* this will send a cold shiver through erik's spine ... */ #define ERR( x ) { ret = x; goto DONE; } -/********************************************************************** - * statics - */ - -#if DEBUG -static int dbg = 1; -#else -static int dbg = 0; -#endif - /********************************************************************* * Call @@ -68,52 +53,54 @@ * Jumps to an arbitrary address. * */ -static int Call( int argc, char *argv[] ) +int call_cmd( int argc, char *argv[] ) { - int ret = 0; + 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 ); + if ( argc < 2 || argc > 6 ) + ERR( -EINVAL ); ret = strtou32( argv[1], &adr ); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); if ( argc >= 3 ) { ret = strtou32( argv[2], &a ); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); } if ( argc >= 4 ) { ret = strtou32( argv[2], &b ); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); } if ( argc >= 5 ) { ret = strtou32( argv[2], &c ); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); } if ( argc >= 6) { ret = strtou32( argv[2], &d ); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); } - printf( "Calling function at address 0x%08lx ...\n", adr ); + dprintf( "calling function at 0x%08x ...\n", adr ); serial_flush_output(); called_fn = (int (*)(u32, u32, u32, u32))adr; ret = called_fn(a, b, c, d); - printf( "Return value: %d == 0x%04x\n", ret, ret ); + dprintf("return value: %d == 0x%04x\n", ret, ret); ret = 0; + DONE: - if ( ret != 0 ) { - perror( ret, __FUNCTION__ ); - } return ret; } -static char callhelp[] = "call address [arg0 [arg1 [arg2 [arg3]]]]\n" +char call_help[] = "call address [arg0 [arg1 [arg2 [arg3]]]]\n" "Call function at <address> with optional arguments\n"; - -__commandlist(Call, "call", callhelp); Index: changebit.c =================================================================== RCS file: /cvsroot/blob/blob/src/commands/changebit.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- changebit.c 12 Feb 2002 12:54:59 -0000 1.1 +++ changebit.c 17 Feb 2002 20:01:31 -0000 1.2 @@ -30,14 +30,9 @@ #endif #include <blob/errno.h> -#include <blob/error.h> #include <blob/types.h> #include <blob/util.h> -#include <blob/serial.h> -#include <blob/command.h> -#include "cmddebug.h" -#include "common.h" /********************************************************************** * defines @@ -48,16 +43,6 @@ #define MEM( x ) (*((u32 *)x)) -/********************************************************************** - * statics - */ - -#if DEBUG -static int dbg = 1; -#else -static int dbg = 0; -#endif - /********************************************************************* * ChangeBit * @@ -67,25 +52,27 @@ * Modifies bits of an given memory location * */ -static int ChangeBit( int argc, char *argv[] ) +int chgbit_cmd( int argc, char *argv[] ) { - int ret = 0; - u32 adr = 0L; - u32 value = 0L; + int ret = 0; + u32 adr, value; - if ( argc < 4 ) ERR( -EINVAL ); + if ( argc < 4 ) + ERR( -EINVAL ); ret = strtou32( argv[1], &adr ); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); ret = strtou32( argv[2], &value ); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); /* check memory alignment */ if(adr &= 0x03) ERR(-EALIGN); - printf( "0x%08lx", MEM( adr ) ); + printf("0x%08x", MEM( adr ) ); switch ( argv[3][0] & (~0x20) ) { case 'A': @@ -106,16 +93,12 @@ break; } - printf( "-> 0x%08lx\n", MEM( adr ) ); + printf( " --> 0x%08x\n", MEM( adr ) ); ret = 0; + DONE: - if ( ret != 0 ) { - perror( ret, __FUNCTION__ ); - } return ret; } -static char chgbithelp[] = "chgbit address value {and|or|xor|set|clear}\n"; - -__commandlist(ChangeBit, "chgbit", chgbithelp ); +char chgbit_help[] = "chgbit address value {and|or|xor|set|clear}\n"; Index: dummy.c =================================================================== RCS file: /cvsroot/blob/blob/src/commands/dummy.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- dummy.c 29 Jan 2002 17:47:23 -0000 1.1 +++ dummy.c 17 Feb 2002 20:01:31 -0000 1.2 @@ -27,7 +27,7 @@ # include <blob/config.h> #endif -#include <blob/serial.h> +#include <blob/util.h> @@ -36,13 +36,8 @@ { int i; - for(i = 0; i < argc; i++) { - SerialOutputString("arg["); - SerialOutputDec(i); - SerialOutputString("] = "); - SerialOutputString(argv[i]); - serial_write('\n'); - } + for(i = 0; i < argc; i++) + printf("argv[%d] = '%s'\n", i, argv[i]); return 0; } Index: dump.c =================================================================== RCS file: /cvsroot/blob/blob/src/commands/dump.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- dump.c 12 Feb 2002 12:54:59 -0000 1.1 +++ dump.c 17 Feb 2002 20:01:31 -0000 1.2 @@ -1,8 +1,7 @@ /* - * dump.c: hextump command + * dump.c: hexdump command * - * Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...> - * Copyright (C) 2001 Tim Riker + * Copyright (C) 2001 Tim Riker <ti...@ri...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,14 +30,10 @@ #endif #include <blob/errno.h> -#include <blob/error.h> +#include <blob/serial.h> #include <blob/types.h> #include <blob/util.h> -#include <blob/serial.h> -#include <blob/command.h> -#include "cmddebug.h" -#include "common.h" /********************************************************************** * defines @@ -47,16 +42,6 @@ /* this will send a cold shiver through erik's spine ... */ #define ERR( x ) { ret = x; goto DONE; } -/********************************************************************** - * statics - */ - -#if DEBUG -static int dbg = 1; -#else -static int dbg = 0; -#endif - /********************************************************************* * dump * @@ -66,13 +51,10 @@ * dumps memory * */ -static int dump( int argc, char *argv[] ) +int dump_cmd( int argc, char *argv[] ) { - int ret = 0; - u32 address; - u32 endaddress; - u32 tmpaddress; - u32 value; + int ret = 0; + u32 address, endaddress, tmpaddress, value; if ( argc < 2 ) ERR( -EINVAL ); @@ -95,10 +77,10 @@ /* print it */ for ( ; address < endaddress; address += 0x10) { - printf( "0x%08lx: ", address ); + printf( "0x%08x: ", address ); for (tmpaddress = address; tmpaddress < address + 0x10; tmpaddress += 4) { value = (*((u32 *)tmpaddress)); - printf( "0x%08lx ", value ); + printf( "0x%08x ", value ); } for (tmpaddress = address; tmpaddress < address + 0x10; tmpaddress++) { value = (*((u8 *)tmpaddress)) & 0xff; @@ -111,13 +93,9 @@ } ret = 0; + DONE: - if ( ret != 0 ) { - perror( ret, __FUNCTION__ ); - } return ret; } -static char dumphelp[] = "dump address [endAddress]\n"; - -__commandlist(dump, "dump", dumphelp ); +char dump_help[] = "dump address [endAddress]\n"; Index: memcpy.c =================================================================== RCS file: /cvsroot/blob/blob/src/commands/memcpy.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- memcpy.c 12 Feb 2002 12:54:59 -0000 1.1 +++ memcpy.c 17 Feb 2002 20:01:31 -0000 1.2 @@ -30,14 +30,9 @@ #endif #include <blob/errno.h> -#include <blob/error.h> +#include <blob/debug.h> #include <blob/types.h> #include <blob/util.h> -#include <blob/serial.h> -#include <blob/command.h> - -#include "cmddebug.h" -#include "common.h" /********************************************************************** @@ -47,16 +42,6 @@ /* this will send a cold shiver through erik's spine ... */ #define ERR( x ) { ret = x; goto DONE; } -/********************************************************************** - * statics - */ - -#if DEBUG -static int dbg = 1; -#else -static int dbg = 0; -#endif - /********************************************************************** * prototypes @@ -71,23 +56,25 @@ * Command wrapper for memcpy utility function. * */ -static int CmdMemcpy( int argc, char *argv[] ) +int memcpy_cmd( int argc, char *argv[] ) { - int ret = 0; - u32 src = 0L; - u32 dest = 0L; - u32 len = 0L; + int ret = 0; + u32 src, dest, len; - if ( argc < 4 ) ERR( -EINVAL ); + if ( argc < 4 ) + ERR( -EINVAL ); ret = strtou32( argv[1], &src ); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); ret = strtou32( argv[2], &dest ); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); ret = strtou32( argv[3], &len ); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); /* check alignment of src and dest */ if((src & 0x03) || (dest & 0x03)) @@ -100,22 +87,17 @@ len = len >> 2; } - _DBG( dbg, "memcpy: src=0x%08lx, dest=0x%08lx, %d words\n", - src, sest, len ); + dprintf("src=0x%08x, dest=0x%08x, %d words\n", src, dest, len ); MyMemCpy( (u32 *)dest, (const u32 *)src, len); printf("%d words copied.\n", len ); ret = 0; + DONE: - if ( ret != 0 ) { - perror( ret, __FUNCTION__ ); - } return ret; } -static char memcpyhelp[] = "memcpy src dst len\n" +char memcpy_help[] = "memcpy src dst len\n" "copy len bytes from src to dst\n"; - -__commandlist(CmdMemcpy, "memcpy", memcpyhelp); Index: peek.c =================================================================== RCS file: /cvsroot/blob/blob/src/commands/peek.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- peek.c 12 Feb 2002 12:54:59 -0000 1.1 +++ peek.c 17 Feb 2002 20:01:31 -0000 1.2 @@ -30,14 +30,9 @@ #endif #include <blob/errno.h> -#include <blob/error.h> +#include <blob/debug.h> #include <blob/types.h> #include <blob/util.h> -#include <blob/serial.h> -#include <blob/command.h> - -#include "cmddebug.h" -#include "common.h" /********************************************************************** @@ -47,16 +42,6 @@ /* this will send a cold shiver through erik's spine ... */ #define ERR( x ) { ret = x; goto DONE; } -/********************************************************************** - * statics - */ - -#if DEBUG -static int dbg = 1; -#else -static int dbg = 0; -#endif - /********************************************************************* * Peek * @@ -66,23 +51,23 @@ * Peeks values from memory * */ -static int Peek( int argc, char *argv[] ) +int peek_cmd( int argc, char *argv[] ) { - int ret = 0; - u32 address; - u32 value; - char type = 'w'; + int ret = 0; + u32 address, value; + char type = 'w'; - if ( argc < 2 ) ERR( -EINVAL ); + if ( argc < 2 ) + ERR( -EINVAL ); ret = strtou32(argv[1], &address); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); - if ( argc >= 2 ) { + if ( argc >= 2 ) type = argv[2][0]; - } - _DBG( dbg, "peek: adr=0x%08lx, type=%c\n", address, type ); + dprintf("adr=0x%08x, type=%c\n", address, type); /* check memory alignment */ switch(type | 0x20) { @@ -130,18 +115,13 @@ break; } - printf( "%c 0x%08lx\n", type, value ); + printf("%c 0x%08x\n", type, value ); ret = 0; + DONE: - if ( ret != 0 ) { - perror( ret, __FUNCTION__ ); - } return ret; } -static char peekhelp[] = "peek address [b|h|w]\n" +char peek_help[] = "peek address [b|h|w]\n" "b = byte, h = half word, w = word (default is w)\n"; - -__commandlist(Peek, "peek", peekhelp ); - Index: poke.c =================================================================== RCS file: /cvsroot/blob/blob/src/commands/poke.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- poke.c 12 Feb 2002 12:54:59 -0000 1.1 +++ poke.c 17 Feb 2002 20:01:31 -0000 1.2 @@ -30,14 +30,9 @@ #endif #include <blob/errno.h> -#include <blob/error.h> +#include <blob/debug.h> #include <blob/types.h> #include <blob/util.h> -#include <blob/serial.h> -#include <blob/command.h> - -#include "cmddebug.h" -#include "common.h" /********************************************************************** @@ -47,19 +42,6 @@ /* this will send a cold shiver through erik's spine ... */ #define ERR( x ) { ret = x; goto DONE; } -/********************************************************************** - * statics - */ - -#if DEBUG -static int dbg = 1; -#else -static int dbg = 0; -#endif - -/********************************************************************** - * prototypes - */ /********************************************************************* * Poke @@ -70,27 +52,28 @@ * Poke values to memory * */ -static int Poke( int argc, char *argv[] ) +int poke_cmd( int argc, char *argv[] ) { - int ret = 0; - u32 address; - u32 value; - char type = 'w'; + int ret = 0; + u32 address, value; + char type = 'w'; - if ( argc < 3 ) ERR( -EINVAL ); + if ( argc < 3 ) + ERR( -EINVAL ); ret = strtou32(argv[1], &address); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); ret = strtou32(argv[2], &value); - if ( ret < 0 ) ERR( -EINVAL ); + if ( ret < 0 ) + ERR( -EINVAL ); - if ( argc >= 3 ) { + if ( argc >= 3 ) type = argv[3][0]; - } - _DBG( dbg, "poke: adr=0x%08lx, val=0x%08lx, type=%c\n", - address, value, type ); + dprintf("adr=0x%08x, val=0x%08x, type=%c\n", + address, value, type ); /* check memory alignment */ switch(type | 0x20) { @@ -138,17 +121,11 @@ break; } - ret = 0; + DONE: - if ( ret != 0 ) { - perror( ret, __FUNCTION__ ); - } return ret; } -static char pokehelp[] = "poke address value [b|h|w]\n" +char poke_help[] = "poke address value [b|h|w]\n" "b = byte, h = half word, w = word (default is w)\n"; - -__commandlist(Poke, "poke", pokehelp ); - --- cmddebug.h DELETED --- --- common.c DELETED --- --- common.h DELETED --- |