2003-06-03 Marcel Telka <marcel@telka.sk>

* src/cmd/Makefile.am (libcmd_a_SOURCES): Removed quit.c, help.c, and detectflash.c.
	* src/cmd/cmd.c (cmd_run, cmd_params, cmd_get_number): Functions moved to module libbrux,
		file cmd/cmd.c.
	* src/cmd/detectflash.c: File moved to module libbrux, directory cmd.
	* src/cmd/help.c: Ditto.
	* src/cmd/quit.c: Ditto.


git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@466 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 22 years ago
parent 6831c9f100
commit 193dcca84e

@ -1,3 +1,12 @@
2003-06-03 Marcel Telka <marcel@telka.sk>
* src/cmd/Makefile.am (libcmd_a_SOURCES): Removed quit.c, help.c, and detectflash.c.
* src/cmd/cmd.c (cmd_run, cmd_params, cmd_get_number): Functions moved to module libbrux,
file cmd/cmd.c.
* src/cmd/detectflash.c: File moved to module libbrux, directory cmd.
* src/cmd/help.c: Ditto.
* src/cmd/quit.c: Ditto.
2003-06-03 Marcel Telka <marcel@telka.sk>
* include/Makefile.am (noinst_HEADERS): Added cmd.h.

@ -26,8 +26,6 @@ include $(top_srcdir)/Makefile.rules
noinst_LIBRARIES = libcmd.a
libcmd_a_SOURCES = \
quit.c \
help.c \
frequency.c \
cable.c \
discovery.c \
@ -41,7 +39,6 @@ libcmd_a_SOURCES = \
endian.c \
peekpoke.c \
readmem.c \
detectflash.c \
flashmem.c \
script.c \
cmd.c

@ -74,58 +74,6 @@ const cmd_t *cmds[] = {
NULL /* last must be NULL */
};
int
cmd_run( char *params[] )
{
int i;
if (!params[0])
return 1;
for (i = 0; cmds[i]; i++)
if (strcmp( cmds[i]->name, params[0] ) == 0) {
int r = cmds[i]->run( params );
if (r < 0)
printf( _("%s: syntax error!\n"), params[0] );
return r;
}
printf( _("%s: unknown command\n"), params[0] );
return 1;
}
int
cmd_params( char *params[] )
{
int i = 0;
while (params[i])
i++;
return i;
}
int
cmd_get_number( char *s, unsigned int *i )
{
int n;
int r;
int l;
if (!s || !i)
return -1;
l = strlen( s );
r = sscanf( s, "0x%x%n", i, &n);
if (r == 1 && n == l)
return 0;
r = sscanf( s, "%u%n", i, &n );
if (r == 1 && n == l)
return 0;
return -1;
}
int
cmd_test_cable( void )
{

@ -1,63 +0,0 @@
/*
* $Id$
*
* Copyright (C) 2003 ETC s.r.o.
*
* 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.
*
* Written by Marcel Telka <marcel@telka.sk>, 2003.
*
*/
#include <config.h>
#include <stdio.h>
#include <brux/flash.h>
#include "cmd.h"
static int
cmd_detectflash_run( char *params[] )
{
if (cmd_params( params ) != 1)
return -1;
if (!bus) {
printf( _("Error: Bus driver missing.\n") );
return 1;
}
detectflash( bus );
return 1;
}
static void
cmd_detectflash_help( void )
{
printf( _(
"Usage: %s\n"
"Detect flash memory type connected to a part.\n"
), "detectflash" );
}
cmd_t cmd_detectflash = {
"detectflash",
N_("detect parameters of flash chips attached to a part"),
cmd_detectflash_help,
cmd_detectflash_run
};

@ -1,79 +0,0 @@
/*
* $Id$
*
* Copyright (C) 2003 ETC s.r.o.
*
* 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.
*
* Written by Marcel Telka <marcel@telka.sk>, 2003.
*
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include "cmd.h"
extern cmd_t *cmds[];
static int
cmd_help_run( char *params[] )
{
int i;
/* short description generation */
if (!params[1]) {
int i;
printf( _("Command list:\n\n") );
for (i = 0; cmds[i]; i++)
printf( _("%-13s %s\n"), cmds[i]->name, cmds[i]->desc ? _(cmds[i]->desc) : _("(no description available)") );
printf( _("\nType \"help COMMAND\" for details about particular command.\n") );
return 1;
}
if (params[2])
return -1;
/* search and print help for particular command */
for (i = 0; cmds[i]; i++)
if (strcmp( cmds[i]->name, params[1] ) == 0) {
if (cmds[i]->help)
cmds[i]->help();
return 1;
}
printf( _("%s: unknown command\n"), params[1] );
return 1;
}
static void
cmd_help_help( void )
{
printf( _(
"Usage: %s [COMMAND]\n"
"Print short help for COMMAND, or list of available commands.\n"
), "help" );
}
cmd_t cmd_help = {
"help",
N_("display this help"),
cmd_help_help,
cmd_help_run
};

@ -1,54 +0,0 @@
/*
* $Id$
*
* Copyright (C) 2003 ETC s.r.o.
*
* 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.
*
* Written by Marcel Telka <marcel@telka.sk>, 2003.
*
*/
#include <config.h>
#include <stdio.h>
#include "cmd.h"
static int
cmd_quit_run( char *params[] )
{
if (params[1])
return -1;
return 0;
}
static void
cmd_quit_help( void )
{
printf( _(
"Usage: %s\n"
"Exit from %s.\n"
), "quit", PACKAGE );
}
cmd_t cmd_quit = {
"quit",
N_("exit from jtag"),
cmd_quit_help,
cmd_quit_run
};
Loading…
Cancel
Save