2003-10-23 Marcel Telka <marcel@telka.sk>

* include/bssignal.h (salias_t): Added new type.
	(salias_alloc, salias_free): Adde new function prototypes.
	* include/part.h (struct part): Added new structure member 'saliases'.
	* src/cmd/Makefile.am (libcmd_a_SOURCES): Added salias.c.
	* src/cmd/cmd.c (cmds): Added cmd_salias.
	* src/cmd/salias.c: New file.
	* src/part/part.c (part_alloc): Added saliases initialization.
	(part_free): Added saliases deallocation.
	(part_find_signal): Added signal aliases searching.
	* src/part/signal.c (salias_alloc, salias_free): New functions.


git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@582 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 21 years ago
parent e02f915ef2
commit 677540b4f0

@ -1,3 +1,16 @@
2003-10-23 Marcel Telka <marcel@telka.sk>
* include/bssignal.h (salias_t): Added new type.
(salias_alloc, salias_free): Adde new function prototypes.
* include/part.h (struct part): Added new structure member 'saliases'.
* src/cmd/Makefile.am (libcmd_a_SOURCES): Added salias.c.
* src/cmd/cmd.c (cmds): Added cmd_salias.
* src/cmd/salias.c: New file.
* src/part/part.c (part_alloc): Added saliases initialization.
(part_free): Added saliases deallocation.
(part_find_signal): Added signal aliases searching.
* src/part/signal.c (salias_alloc, salias_free): New functions.
2003-10-20 Marcel Telka <marcel@telka.sk>
* data/hitachi/hd64465/hd64465: Completed BSR bits declaration.

@ -5,6 +5,7 @@ See libbrux/NEWS for more news.
* Added new JTAG declarations for
- Hitachi HD64465
- Hitachi SH7729 (Beregnyei Balazs)
* Added new command 'salias'.
jtag-0.5.1 (2003-10-11):

@ -2,6 +2,7 @@
* $Id$
*
* Copyright (C) 2002 ETC s.r.o.
* Copyright (C) 2003 Marcel Telka
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -18,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by Marcel Telka <marcel@telka.sk>, 2002.
* Written by Marcel Telka <marcel@telka.sk>, 2002, 2003.
*
*/
@ -36,7 +37,18 @@ struct signal {
bsbit_t *output;
};
typedef struct salias salias_t;
struct salias {
char *name;
salias_t *next;
signal_t *signal;
};
signal_t *signal_alloc( const char *name );
void signal_free( signal_t *s );
salias_t *salias_alloc( const char *name, const signal_t *signal );
void salias_free( salias_t *salias );
#endif /* SIGNAL_H */

@ -44,6 +44,7 @@ struct part {
char part[MAXLEN_PART + 1];
char stepping[MAXLEN_STEPPING + 1];
signal_t *signals;
salias_t *saliases;
int instruction_length;
instruction *instructions;
instruction *active_instruction;

@ -31,6 +31,7 @@ libcmd_a_SOURCES = \
discovery.c \
detect.c \
signal.c \
salias.c \
bit.c \
register.c \
initbus.c \

@ -38,6 +38,7 @@ extern cmd_t cmd_cable;
extern cmd_t cmd_discovery;
extern cmd_t cmd_detect;
extern cmd_t cmd_signal;
extern const cmd_t cmd_salias;
extern cmd_t cmd_bit;
extern cmd_t cmd_register;
extern const cmd_t cmd_initbus;
@ -67,6 +68,7 @@ const cmd_t *cmds[] = {
&cmd_discovery,
&cmd_detect,
&cmd_signal,
&cmd_salias,
&cmd_bit,
&cmd_register,
&cmd_initbus,

@ -0,0 +1,99 @@
/*
* $Id$
*
* Copyright (C) 2003 Marcel Telka
*
* 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 "sysdep.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "jtag.h"
#include "cmd.h"
static int
cmd_salias_run( char *params[] )
{
part_t *part;
signal_t *s;
salias_t *sa;
if (cmd_params( params ) != 3)
return -1;
if (!cmd_test_cable())
return 1;
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
if (chain->active_part >= chain->parts->len) {
printf( _("%s: no active part\n"), "signal" );
return 1;
}
part = chain->parts->parts[chain->active_part];
if (part_find_signal( part, params[1] ) != NULL) {
printf( _("Signal '%s' already defined\n"), params[1] );
return 1;
}
s = part_find_signal( part, params[2] );
if (s == NULL) {
printf( _("Signal '%s' not found\n"), params[2] );
return 1;
}
sa = salias_alloc( params[1], s );
if (!sa) {
printf( _("out of memory\n") );
return 1;
}
sa->next = part->saliases;
part->saliases = sa;
return 1;
}
static void
cmd_salias_help( void )
{
printf( _(
"Usage: %s ALIAS SIGNAL\n"
"Define new signal ALIAS as alias for existing SIGNAL.\n"
"\n"
"ALIAS New signal alias name\n"
"SIGNAL Existing signal name\n"
), "signal" );
}
const cmd_t cmd_salias = {
"salias",
N_("define an alias for a signal"),
cmd_salias_help,
cmd_salias_run
};

@ -43,6 +43,7 @@ part_alloc( const tap_register *id )
p->part[0] = '\0';
p->stepping[0] = '\0';
p->signals = NULL;
p->saliases = NULL;
p->instruction_length = 0;
p->instructions = NULL;
p->active_instruction = NULL;
@ -71,6 +72,13 @@ part_free( part_t *p )
signal_free( s );
}
/* saliases */
while (p->saliases) {
salias_t *sa = p->saliases;
p->saliases = sa->next;
salias_free( sa );
}
/* instructions */
while (p->instructions) {
instruction *i = p->instructions;
@ -133,6 +141,7 @@ signal_t *
part_find_signal( part_t *p, const char *signalname )
{
signal_t *s;
salias_t *sa;
if (!p || !signalname)
return NULL;
@ -140,11 +149,18 @@ part_find_signal( part_t *p, const char *signalname )
s = p->signals;
while (s) {
if (strcmp( signalname, s->name ) == 0)
break;
return s;
s = s->next;
}
return s;
sa = p->saliases;
while (sa) {
if (strcmp( signalname, sa->name ) == 0)
return sa->signal;
sa = sa->next;
}
return NULL;
}
void

@ -54,3 +54,29 @@ signal_free( signal_t *s )
free( s->name );
free( s );
}
salias_t *
salias_alloc( const char *name, const signal_t *signal )
{
salias_t *sa = malloc( sizeof *sa );
if (sa == NULL)
return NULL;
sa->name = strdup( name );
if (sa->name == NULL) {
free( sa );
return NULL;
}
sa->next = NULL;
sa->signal = signal;
return sa;
}
void salias_free( salias_t *salias )
{
if (salias == NULL)
return;
free( salias->name );
free( salias );
}

Loading…
Cancel
Save