2003-08-11 Marcel Telka <marcel@telka.sk>
* include/bus.h (buses_t): Added new structure. * src/jtag.c (bus): Removed global variable. * src/bus/Makefile.am (libbus_a_SOURCES): Added buses.c. * src/bus/buses.c: New file. * src/bus/bcm1250.c (bcm1250_bus_printinfo): New function. * src/bus/ixp425.c (ixp425_bus_printinfo): Ditto. * src/bus/pxa2x0.c (pxa2x0_bus_printinfo): Ditto. * src/bus/sa1110.c (sa1110_bus_printinfo): Ditto. * src/bus/sh7727.c (sh7727_bus_printinfo): Ditto. * src/bus/sh7750r.c (sh7750r_bus_printinfo): Ditto. * src/cmd/Makefile.am (libcmd_a_SOURCES): Added bus.c. * src/cmd/bus.c: New file. * src/cmd/cmd.c (cmds): Added cmd_bus. * src/cmd/detect.c (cmd_detect_run): Added support for multiple buses detection. * src/cmd/print.c (cmd_print_run): Fixed header printing while syntax error. Added support for printing list of active buses. (cmd_print_help): Added new parameter 'bus'. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@497 b68d4a1b-bc3d-0410-92ed-d4ac073336b7master
parent
aa38f7e886
commit
7cca05a558
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* $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 <stdlib.h>
|
||||
|
||||
#include "bus.h"
|
||||
|
||||
bus_t *bus = NULL;
|
||||
buses_t buses = {0, NULL};
|
||||
|
||||
void buses_free( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < buses.len; i++)
|
||||
bus_free( buses.buses[i] );
|
||||
|
||||
free( buses.buses );
|
||||
buses.len = 0;
|
||||
buses.buses = NULL;
|
||||
bus = NULL;
|
||||
}
|
||||
|
||||
void buses_add( bus_t *abus )
|
||||
{
|
||||
bus_t **b;
|
||||
|
||||
if (abus == NULL)
|
||||
return;
|
||||
|
||||
b = realloc( buses.buses, (buses.len + 1) * sizeof (bus_t *) );
|
||||
if (b == NULL) {
|
||||
printf( _("Out of memory\n") );
|
||||
return;
|
||||
}
|
||||
buses.buses = b;
|
||||
buses.buses[buses.len++] = abus;
|
||||
if (bus == NULL)
|
||||
bus = abus;
|
||||
}
|
||||
|
||||
void buses_delete( bus_t *abus )
|
||||
{
|
||||
int i;
|
||||
bus_t **b;
|
||||
|
||||
for (i = 0; i < buses.len; i++)
|
||||
if (abus == buses.buses[i])
|
||||
break;
|
||||
if (i >= buses.len)
|
||||
return;
|
||||
|
||||
while (i + 1 < buses.len) {
|
||||
buses.buses[i] = buses.buses[i + 1];
|
||||
i++;
|
||||
}
|
||||
buses.len--;
|
||||
b = realloc( buses.buses, buses.len * sizeof (bus_t *) );
|
||||
if ((b != NULL) || (buses.len == 0))
|
||||
buses.buses = b;
|
||||
|
||||
if (bus != abus)
|
||||
return;
|
||||
|
||||
if (buses.len > 0)
|
||||
bus = buses.buses[0];
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* $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 "jtag.h"
|
||||
|
||||
#include "cmd.h"
|
||||
|
||||
static int
|
||||
cmd_bus_run( char *params[] )
|
||||
{
|
||||
unsigned int n;
|
||||
|
||||
if (cmd_params( params ) != 2)
|
||||
return -1;
|
||||
|
||||
if (!cmd_test_cable())
|
||||
return 1;
|
||||
|
||||
if (!chain->parts) {
|
||||
printf( _("Run \"detect\" first.\n") );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (cmd_get_number( params[1], &n ))
|
||||
return -1;
|
||||
|
||||
if (n >= buses.len) {
|
||||
printf( _("%s: invalid bus number\n"), "bus" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
bus = buses.buses[n];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_bus_help( void )
|
||||
{
|
||||
printf( _(
|
||||
"Usage: %s BUS\n"
|
||||
"Change active bus.\n"
|
||||
"\n"
|
||||
"BUS bus number\n"
|
||||
), "bus" );
|
||||
}
|
||||
|
||||
cmd_t cmd_bus = {
|
||||
"bus",
|
||||
N_("change active bus"),
|
||||
cmd_bus_help,
|
||||
cmd_bus_run
|
||||
};
|
Loading…
Reference in New Issue