From: Erik M. <er...@us...> - 2002-02-17 20:03:45
|
Update of /cvsroot/blob/blob/src/diag In directory usw-pr-cvs1:/tmp/cvs-serv28493/src/diag Modified Files: .cvsignore Makefile.am regs-sa11x0.c Added Files: getcommand.c Removed Files: commands.c Log Message: Add infrastructure to select at compile-time which commands should be linked with blob. --- NEW FILE: getcommand.c --- /* * getcommand.c: commands for diag * * Copyright (C) 2001 Erik Mouw <J.A...@it...> * * $Id: getcommand.c,v 1.1 2002/02/17 20:03:41 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 * */ #ident "$Id: getcommand.c,v 1.1 2002/02/17 20:03:41 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/command.h> #include <blob/command_hist.h> #include <blob/error.h> #include <blob/serial.h> #include <blob/time.h> #include <blob/util.h> /* more or less like SerialInputString(), but with echo and backspace */ /* unlike the version in libblob, this version has a command history */ int GetCommand(char *command, int len, int timeout) { u32 startTime, currentTime; int c; int i; int numRead; int maxRead = len - 1; TimerClearOverflow(); startTime = TimerGetTime(); cmdhist_reset(); for(numRead = 0, i = 0; numRead < maxRead;) { /* try to get a byte from the serial port */ while(serial_poll() != 0) { currentTime = TimerGetTime(); /* check timeout value */ if((currentTime - startTime) > (timeout * TICKS_PER_SECOND)) { /* timeout */ command[i++] = '\0'; cmdhist_push( command ); return(numRead); } } c = serial_read(); /* check for errors */ if(c < 0) { command[i++] = '\0'; serial_write('\n'); printerror(c, "can't read command"); return c; } if((c == '\r') || (c == '\n')) { command[i++] = '\0'; /* print newline */ serial_write('\n'); cmdhist_push( command ); return(numRead); } else if(c == '\b') { /* FIXME: is this backspace? */ if(i > 0) { i--; numRead--; /* cursor one position back. */ SerialOutputString("\b \b"); } } else if ( c == CMDHIST_KEY_UP ) { char *cmd = NULL; /* get cmd from history */ if ( cmdhist_next( &cmd ) != 0 ) continue; /* clear line */ while ( numRead-- ) { SerialOutputString("\b \b"); } /* display it */ SerialOutputString(cmd); i = numRead = strlen( cmd ); strncpy( command, cmd, MAX_COMMANDLINE_LENGTH ); } else if ( c == CMDHIST_KEY_DN ) { char *cmd = NULL; /* get cmd from history */ if ( cmdhist_prev( &cmd ) != 0 ) continue; /* clear line */ while ( numRead-- ) { SerialOutputString("\b \b"); } /* display it */ SerialOutputString(cmd); i = numRead = strlen( cmd ); strncpy( command, cmd, MAX_COMMANDLINE_LENGTH ); } else { command[i++] = c; numRead++; /* print character */ serial_write(c); } } cmdhist_push( command ); return(numRead); } Index: .cvsignore =================================================================== RCS file: /cvsroot/blob/blob/src/diag/.cvsignore,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- .cvsignore 11 Feb 2002 22:50:59 -0000 1.3 +++ .cvsignore 17 Feb 2002 20:03:41 -0000 1.4 @@ -1,5 +1,6 @@ Makefile.in Makefile +commands.c diag diag-elf32 *.o Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/diag/Makefile.am,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- Makefile.am 17 Feb 2002 15:41:54 -0000 1.13 +++ Makefile.am 17 Feb 2002 20:03:41 -0000 1.14 @@ -32,12 +32,24 @@ -I${top_srcdir}/include +# ---- Built sources ------------------------------------------------- + +BUILT_SOURCES = \ + commands.c + +commands.c: + ${top_srcdir}/src/commands/make_commands.sh @ALL_COMMANDS@ > $@ + + +# ---- diag ---------------------------------------------------------- + # WARNING: start.S *must* be the first file, otherwise the target will # be linked in the wrong order! diag_elf32_SOURCES = \ start.S \ command_hist.c \ commands.c \ + getcommand.c \ initcalls.c \ regs-sa11x0.c \ main.c @@ -86,11 +98,13 @@ $(OBJCOPY) $(OCFLAGS) $< $@ +# ---- Automake administrativia -------------------------------------- + EXTRA_DIST = \ ld-script -CLEANFILES = ${srcdir}/*~ *.map +CLEANFILES = ${srcdir}/*~ *.map commands.c DISTCLEANFILES = ${builddir}/.deps/*.P Index: regs-sa11x0.c =================================================================== RCS file: /cvsroot/blob/blob/src/diag/regs-sa11x0.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- regs-sa11x0.c 11 Feb 2002 16:53:16 -0000 1.4 +++ regs-sa11x0.c 17 Feb 2002 20:03:41 -0000 1.5 @@ -224,6 +224,15 @@ /**********************************************************************/ /**********************************************************************/ +/********************************************************************** + * regs_show() + * + * AUTHOR: seletz + * REVISED: + * + * Display register contents + * + */ static int regs_show( int argc, char *argv[] ) { int i = 0; @@ -237,17 +246,11 @@ while ( reg_sets[set].name ) { i = 0; registers = reg_sets[set].set; - SerialOutputString( reg_sets[set].name ); - serial_write( '\n' ); - SerialOutputString( "--------------------------------\n" ); + printf( "%s\n", reg_sets[set].name ); + printf( "--------------------------------\n" ); while ( registers && registers[i].name ) { - SerialOutputString( registers[i].name ); - SerialOutputString( "= 0x" ); - SerialOutputHex( MEM( registers[i].adr ) ); - if ( registers[i].desc ) { - SerialOutputString( registers[i].desc ); - } - serial_write( '\n' ); + printf( "%s= 0x%08x %s\n", registers[i].name, MEM( registers[i].adr ), + registers[i].desc?registers[i].desc:"" ); i++; } set++; @@ -256,5 +259,7 @@ return 0; } + static char regshelp[] = "print register info\n"; + __commandlist(regs_show, "regs", regshelp); --- commands.c DELETED --- |