diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 23af221d..5a31241d 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,62 @@ +2003-09-05 Marcel Telka + + * include/bus.h (bus_drivers): Added constant declaration. + (new_sa1110_bus, new_pxa250_bus, new_ixp425_bus, new_sh7727_bus, new_sh7750r_bus, new_sh7751r_bus) + (new_bcm1250_bus): Function declarations removed. + * src/bus/buses.c (bus_drivers): New constant definition. + * src/bus/buses.h: New file. + * src/bus/Makefile.am (libbus_a_SOURCES): Added buses.h. + + * src/bus/bcm1250.c (bcm1250_bus_printinfo): Added new function parameter 'bus'. + (bcm1250_bus): Changed structure type to bus_driver_t. Changed members. + (new_bcm1250_bus): Function renamed ... + (bcm1250_bus_new): ... to this one. Changed parameter list to void (and function body updated). + * src/bus/ixp425.c (ixp425_bus_printinfo): Added new function parameter 'bus'. + (ixp425_bus): Changed structure type to bus_driver_t. Changed members. + (new_ixp425_bus): Function renamed ... + (ixp425_bus_new): ... to this one. Changed parameter list to void (and function body updated). + * src/bus/pxa2x0.c (pxa2x0_bus_printinfo): Added new function parameter 'bus'. + (pxa250_bus): Structure transformed ... + (pxa2x0_bus): ... to this constant (changed type to bus_driver_t, changed members). + (new_pxa250_bus): Function renamed ... + (pxa2x0_bus_new): ... to this one. Changed parameter list to void (and function body updated). + * src/bus/s3c4510x.c (s3c4510_bus_printinfo): Added new function parameter 'bus'. + (s3c4510_bus): Changed structure type to bus_driver_t. Changed members. + (new_s3c4510_bus): Function renamed ... + (s3c4510_bus_new): ... to this one. Changed parameter list to void (and function body updated). + * src/bus/sa1110.c (sa1110_bus_printinfo): Added new function parameter 'bus'. + (sa1110_bus): Changed structure type to bus_driver_t. Changed members. + (new_sa1110_bus): Function renamed ... + (sa1110_bus_new): ... to this one. Changed parameter list to void (and function body updated). + * src/bus/sh7727.c (sh7727_bus_printinfo): Added new function parameter 'bus'. + (sh7727_bus): Changed structure type to bus_driver_t. Changed members. + (new_sh7727_bus): Function renamed ... + (sh7727_bus_new): ... to this one. Changed parameter list to void (and function body updated). + * src/bus/sh7750r.c (sh7750r_bus_printinfo): Added new function parameter 'bus'. + (sh7750r_bus): Changed structure type to bus_driver_t. Changed members. + (new_sh7750r_bus): Function renamed ... + (sh7750r_bus_new): ... to this one. Changed parameter list to void (and function body updated). + * src/bus/sh7751r.c (sh7751r_bus_printinfo): Added new function parameter 'bus'. + (sh7751r_bus): Changed structure type to bus_driver_t. Changed members. + (new_sh7751r_bus): Function renamed ... + (sh7751r_bus_new): ... to this one. Changed parameter list to void (and function body updated). + + * src/cmd/cable.c (cmd_cable_run): Replaced bus->free() call with bus_free(). + * src/jtag.c (main): Ditto. + + * src/cmd/cmd.c (cmds): Added cmd_initbus. + * src/cmd/detect.c (cmd_detect_run): Removed explicit bus driver detection. + * src/cmd/initbus.c: New file. + * src/cmd/Makefile.am (libcmd_a_SOURCES): Added initbus.c. + + * data/broadcom/bcm1250/bcm1250: Added 'initbus' command call. + * data/hitachi/sh7727/sh7727: Ditto. + * data/intel/ixp425/ixp425: Ditto. + * data/intel/pxa250/pxa250: Ditto. + * data/intel/pxa250/pxa250c0: Ditto. + * data/intel/sa1110/sa1110: Ditto. + * data/samsung/s3c4510b/s3c4510b: Ditto. + 2003-09-04 Marcel Telka * configure.ac (CPPFLAGS): Added top_srcdir into include directory list. diff --git a/jtag/NEWS b/jtag/NEWS index cb0c4af6..97010e19 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -9,6 +9,7 @@ See libbrux/NEWS for more news. of the cable (patch 793313, Rojhalat Ibrahim). * Used real data bus width for data reading in PXA2x0, SA1110, and SH7727 bus drivers (based on patch 792591, thanks to Guennadi Liakhovetski). + * Added 'initbus' command to allow dynamic bus driver loading. * Added BOOT_DEF register emulation for PXA2x0 bus driver. * Fixed minor bugs. diff --git a/jtag/TODO b/jtag/TODO index 1586db8d..6dc501bc 100644 --- a/jtag/TODO +++ b/jtag/TODO @@ -1,7 +1,6 @@ $Id$ * Write documentation. -* Add 'initbus' command to allow dynamic bus driver loading. * Support for display the result of a boundary scan formated according to the CPU definitions (e.g. MA[0-26] = 0x00001c00). * Remove direct relation between JTAG instruction and data register (e.g. ARM7TDMI). * SVF player. diff --git a/jtag/data/broadcom/bcm1250/bcm1250 b/jtag/data/broadcom/bcm1250/bcm1250 index a45c7371..a8b4916d 100644 --- a/jtag/data/broadcom/bcm1250/bcm1250 +++ b/jtag/data/broadcom/bcm1250/bcm1250 @@ -2338,3 +2338,5 @@ bit 3 I 1 P_AD29 bit 2 O 1 P_AD31 1 0 Z bit 1 C 0 * bit 0 I 1 P_AD31 + +initbus bcm1250 diff --git a/jtag/data/hitachi/sh7727/sh7727 b/jtag/data/hitachi/sh7727/sh7727 index 062bc981..a888b13a 100644 --- a/jtag/data/hitachi/sh7727/sh7727 +++ b/jtag/data/hitachi/sh7727/sh7727 @@ -669,3 +669,5 @@ bit 3 C 1 * bit 2 C 1 * bit 1 C 1 * bit 0 C 1 * + +initbus sh7727 diff --git a/jtag/data/intel/ixp425/ixp425 b/jtag/data/intel/ixp425/ixp425 index 572c5420..5b086a93 100644 --- a/jtag/data/intel/ixp425/ixp425 +++ b/jtag/data/intel/ixp425/ixp425 @@ -630,3 +630,5 @@ bit 3 C ? . bit 2 C ? . bit 1 C ? . bit 0 C ? . + +initbus ixp425 diff --git a/jtag/data/intel/pxa250/pxa250 b/jtag/data/intel/pxa250/pxa250 index 381c6524..ad47bcf3 100644 --- a/jtag/data/intel/pxa250/pxa250 +++ b/jtag/data/intel/pxa250/pxa250 @@ -638,3 +638,5 @@ bit 3 C ? . bit 2 C ? . bit 1 C ? . bit 0 C ? . + +initbus pxa2x0 diff --git a/jtag/data/intel/pxa250/pxa250c0 b/jtag/data/intel/pxa250/pxa250c0 index 6b2d701e..4aa93a9e 100644 --- a/jtag/data/intel/pxa250/pxa250c0 +++ b/jtag/data/intel/pxa250/pxa250c0 @@ -665,3 +665,5 @@ bit 3 C ? . bit 2 C ? . bit 1 C ? . bit 0 C ? . + +initbus pxa2x0 diff --git a/jtag/data/intel/sa1110/sa1110 b/jtag/data/intel/sa1110/sa1110 index bc4ce359..fb90b90a 100644 --- a/jtag/data/intel/sa1110/sa1110 +++ b/jtag/data/intel/sa1110/sa1110 @@ -512,3 +512,5 @@ bit 3 I ? TXD_3 bit 2 I ? nRESET bit 1 O 1 nRESET_OUT bit 0 I ? ROM_SEL + +initbus sa1110 diff --git a/jtag/data/samsung/s3c4510b/s3c4510b b/jtag/data/samsung/s3c4510b/s3c4510b index 4a5cfe3f..9f88b28f 100644 --- a/jtag/data/samsung/s3c4510b/s3c4510b +++ b/jtag/data/samsung/s3c4510b/s3c4510b @@ -453,3 +453,5 @@ bit 3 I ? nUADTR0 bit 2 O ? UATXD0 bit 1 O ? nUADSR0 bit 0 I ? UARXD1 + +initbus s3c4510x diff --git a/jtag/include/bus.h b/jtag/include/bus.h index e64af6d5..7766c95a 100644 --- a/jtag/include/bus.h +++ b/jtag/include/bus.h @@ -37,17 +37,10 @@ typedef struct { } buses_t; extern buses_t buses; +extern const bus_driver_t *bus_drivers[]; void buses_free( void ); void buses_add( bus_t *abus ); void buses_delete( bus_t *abus ); -bus_t *new_sa1110_bus( chain_t *chain, int pn ); -bus_t *new_pxa250_bus( chain_t *chain, int pn ); -bus_t *new_ixp425_bus( chain_t *chain, int pn ); -bus_t *new_sh7727_bus( chain_t *chain, int pn ); -bus_t *new_sh7750r_bus( chain_t *chain, int pn ); -bus_t *new_sh7751r_bus( chain_t *chain, int pn ); -bus_t *new_bcm1250_bus( chain_t *chain, int pn ); - #endif /* BUS_H */ diff --git a/jtag/src/bus/Makefile.am b/jtag/src/bus/Makefile.am index ec39cc6e..4a0c660f 100644 --- a/jtag/src/bus/Makefile.am +++ b/jtag/src/bus/Makefile.am @@ -27,6 +27,7 @@ noinst_LIBRARIES = libbus.a libbus_a_SOURCES = \ buses.c \ + buses.h \ bcm1250.c \ ixp425.c \ pxa2x0.c \ diff --git a/jtag/src/bus/bcm1250.c b/jtag/src/bus/bcm1250.c index 7db7305f..000a7088 100644 --- a/jtag/src/bus/bcm1250.c +++ b/jtag/src/bus/bcm1250.c @@ -20,7 +20,7 @@ * 02111-1307, USA. * * Written by Matan Ziv-Av. - * MOdified by Marcel Telka , 2003. + * Modified by Marcel Telka , 2003. * */ @@ -34,6 +34,8 @@ #include "bus.h" #include "chain.h" #include "bssignal.h" +#include "jtag.h" +#include "buses.h" #ifdef USE_BCM_EJTAG int bcm1250_ejtag_do(bus_t *, uint64_t, uint64_t, int, int, unsigned char *, int); @@ -92,7 +94,7 @@ setup_data( bus_t *bus, uint32_t d ) #ifndef USE_BCM_EJTAG static void -bcm1250_bus_printinfo( void ) +bcm1250_bus_printinfo( bus_t *bus ) { int i; @@ -266,8 +268,13 @@ bcm1250_bus_free( bus_t *bus ) free( bus ); } -static const bus_t bcm1250_bus = { - NULL, +static bus_t *bcm1250_bus_new( void ); + +const bus_driver_t bcm1250_bus = { + "bcm1250", + N_("Broadcom BCM1250 compatibile bus driver via BSR"), + bcm1250_bus_new, + bcm1250_bus_free, bcm1250_bus_printinfo, bcm1250_bus_prepare, bcm1250_bus_area, @@ -275,27 +282,25 @@ static const bus_t bcm1250_bus = { bcm1250_bus_read_next, bcm1250_bus_read_end, bcm1250_bus_read, - bcm1250_bus_write, - bcm1250_bus_free + bcm1250_bus_write }; -bus_t * -new_bcm1250_bus( chain_t *chain, int pn ) +static bus_t * +bcm1250_bus_new( void ) { bus_t *bus; char buff[10]; int i; int failed = 0; - if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) - return NULL; + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; bus = malloc( sizeof (bus_t) ); if (!bus) return NULL; - memcpy( bus, &bcm1250_bus, sizeof (bus_t) ); - + bus->driver = & bcm1250_bus; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); @@ -303,7 +308,7 @@ new_bcm1250_bus( chain_t *chain, int pn ) } CHAIN = chain; - PART = chain->parts->parts[pn]; + PART = chain->parts->parts[chain->active_part]; for (i = 0; i < 32; i++) { sprintf( buff, "IO_AD%d", i ); diff --git a/jtag/src/bus/buses.c b/jtag/src/bus/buses.c index 0a22785c..558e6172 100644 --- a/jtag/src/bus/buses.c +++ b/jtag/src/bus/buses.c @@ -27,6 +27,19 @@ #include #include "bus.h" +#include "buses.h" + +const bus_driver_t *bus_drivers[] = { + &bcm1250_bus, + &ixp425_bus, + &pxa2x0_bus, + &s3c4510_bus, + &sa1110_bus, + &sh7727_bus, + &sh7750r_bus, + &sh7751r_bus, + NULL /* last must be NULL */ +}; bus_t *bus = NULL; buses_t buses = {0, NULL}; diff --git a/jtag/src/bus/buses.h b/jtag/src/bus/buses.h new file mode 100644 index 00000000..ec27a12b --- /dev/null +++ b/jtag/src/bus/buses.h @@ -0,0 +1,37 @@ +/* + * $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 , 2003. + * + */ + +#ifndef BUSES_H +#define BUSES_H + +extern const bus_driver_t bcm1250_bus; +extern const bus_driver_t ixp425_bus; +extern const bus_driver_t pxa2x0_bus; +extern const bus_driver_t s3c4510_bus; +extern const bus_driver_t sa1110_bus; +extern const bus_driver_t sh7727_bus; +extern const bus_driver_t sh7750r_bus; +extern const bus_driver_t sh7751r_bus; + +#endif /* BUSES_H */ diff --git a/jtag/src/bus/ixp425.c b/jtag/src/bus/ixp425.c index c772d3e4..603fcd92 100644 --- a/jtag/src/bus/ixp425.c +++ b/jtag/src/bus/ixp425.c @@ -33,6 +33,8 @@ #include "bus.h" #include "chain.h" #include "bssignal.h" +#include "jtag.h" +#include "buses.h" typedef struct { chain_t *chain; @@ -113,7 +115,7 @@ setup_data( bus_t *bus, uint32_t d ) } static void -ixp425_bus_printinfo( void ) +ixp425_bus_printinfo( bus_t *bus ) { int i; @@ -229,9 +231,13 @@ ixp425_bus_free( bus_t *bus ) free( bus ); } +static bus_t *ixp425_bus_new( void ); -static const bus_t ixp425_bus = { - NULL, +const bus_driver_t ixp425_bus = { + "ixp425", + N_("Intel IXP425 compatibile bus driver via BSR"), + ixp425_bus_new, + ixp425_bus_free, ixp425_bus_printinfo, ixp425_bus_prepare, ixp425_bus_area, @@ -239,27 +245,25 @@ static const bus_t ixp425_bus = { ixp425_bus_read_next, ixp425_bus_read_end, ixp425_bus_read, - ixp425_bus_write, - ixp425_bus_free + ixp425_bus_write }; -bus_t * -new_ixp425_bus( chain_t *chain, int pn ) +static bus_t * +ixp425_bus_new( void ) { bus_t *bus; char buff[15]; int i; int failed = 0; - if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; bus = malloc( sizeof (bus_t) ); if (!bus) return NULL; - memcpy( bus, &ixp425_bus, sizeof (bus_t) ); - + bus->driver = &ixp425_bus; bus->params = malloc( sizeof (bus_params_t) ); if (!bus->params) { free( bus ); @@ -267,7 +271,7 @@ new_ixp425_bus( chain_t *chain, int pn ) } CHAIN = chain; - PART = chain->parts->parts[pn]; + PART = chain->parts->parts[chain->active_part]; for (i = 0; i < 8; i++) { sprintf( buff, "EX_CS[%d]", i ); diff --git a/jtag/src/bus/pxa2x0.c b/jtag/src/bus/pxa2x0.c index 5c1954a3..c96a815d 100644 --- a/jtag/src/bus/pxa2x0.c +++ b/jtag/src/bus/pxa2x0.c @@ -38,6 +38,8 @@ #include "part.h" #include "bus.h" #include "bssignal.h" +#include "jtag.h" +#include "buses.h" typedef struct { chain_t *chain; @@ -107,7 +109,7 @@ setup_data( bus_t *bus, uint32_t adr, uint32_t d ) } static void -pxa2x0_bus_printinfo( void ) +pxa2x0_bus_printinfo( bus_t *bus ) { int i; @@ -335,8 +337,13 @@ pxa250_bus_free( bus_t *bus ) free( bus ); } -static const bus_t pxa250_bus = { - NULL, +static bus_t *pxa2x0_bus_new( void ); + +const bus_driver_t pxa2x0_bus = { + "pxa2x0", + N_("Intel PXA2x0 compatibile bus driver via BSR"), + pxa2x0_bus_new, + pxa250_bus_free, pxa2x0_bus_printinfo, pxa250_bus_prepare, pxa2x0_bus_area, @@ -344,27 +351,25 @@ static const bus_t pxa250_bus = { pxa250_bus_read_next, pxa250_bus_read_end, pxa250_bus_read, - pxa250_bus_write, - pxa250_bus_free + pxa250_bus_write }; -bus_t * -new_pxa250_bus( chain_t *chain, int pn ) +static bus_t * +pxa2x0_bus_new( void ) { bus_t *bus; char buff[10]; int i; int failed = 0; - if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; - + bus = malloc( sizeof (bus_t) ); if (!bus) return NULL; - memcpy( bus, &pxa250_bus, sizeof (bus_t) ); - + bus->driver = &pxa2x0_bus; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); @@ -372,7 +377,7 @@ new_pxa250_bus( chain_t *chain, int pn ) } CHAIN = chain; - PART = chain->parts->parts[pn]; + PART = chain->parts->parts[chain->active_part]; for (i = 0; i < 26; i++) { sprintf( buff, "MA[%d]", i ); diff --git a/jtag/src/bus/s3c4510x.c b/jtag/src/bus/s3c4510x.c index 549ad9ce..3a3ec1d6 100644 --- a/jtag/src/bus/s3c4510x.c +++ b/jtag/src/bus/s3c4510x.c @@ -55,6 +55,8 @@ #include "bus.h" #include "chain.h" #include "bssignal.h" +#include "jtag.h" +#include "buses.h" /** @brief Bus driver for Samsung S3C4510X */ @@ -116,7 +118,7 @@ setup_data( bus_t *bus, uint32_t d ) } static void -s3c4510_bus_printinfo( void ) +s3c4510_bus_printinfo( bus_t *bus ) { int i; @@ -288,8 +290,13 @@ s3c4510_bus_free( bus_t *bus ) free( bus ); } -static const bus_t s3c4510_bus = { - NULL, +static bus_t *s3c4510_bus_new( void ); + +const bus_driver_t s3c4510_bus = { + "s3c4510x", + N_("Samsung S3C4510B compatibile bus driver via BSR"), + s3c4510_bus_new, + s3c4510_bus_free, s3c4510_bus_printinfo, s3c4510_bus_prepare, s3c4510_bus_area, @@ -297,35 +304,33 @@ static const bus_t s3c4510_bus = { s3c4510_bus_read_next, s3c4510_bus_read_end, s3c4510_bus_read, - s3c4510_bus_write, - s3c4510_bus_free + s3c4510_bus_write }; -bus_t * -new_s3c4510_bus( chain_t *chain, int pn ) +static bus_t * +s3c4510_bus_new( void ) { bus_t *bus; char buff[10]; int i; int failed = 0; - if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; bus = malloc( sizeof (bus_t) ); if (!bus) return NULL; - memcpy( bus, &s3c4510_bus, sizeof (bus_t) ); - - bus->params = malloc( sizeof (bus_params_t) ); + bus->driver = &s3c4510_bus; + bus->params = malloc( sizeof (bus_params_t) ); if (!bus->params) { free( bus ); return NULL; } CHAIN = chain; - PART = chain->parts->parts[pn]; + PART = chain->parts->parts[chain->active_part]; for (i = 0; i < 22; i++) { sprintf( buff, "ADDR%d", i ); @@ -383,6 +388,66 @@ new_s3c4510_bus( chain_t *chain, int pn ) ** ** CVS Log ** $Log$ +** Revision 1.4 2003/09/05 21:09:14 telka +** 2003-09-05 Marcel Telka +** +** * include/bus.h (bus_drivers): Added constant declaration. +** (new_sa1110_bus, new_pxa250_bus, new_ixp425_bus, new_sh7727_bus, new_sh7750r_bus, new_sh7751r_bus) +** (new_bcm1250_bus): Function declarations removed. +** * src/bus/buses.c (bus_drivers): New constant definition. +** * src/bus/buses.h: New file. +** * src/bus/Makefile.am (libbus_a_SOURCES): Added buses.h. +** +** * src/bus/bcm1250.c (bcm1250_bus_printinfo): Added new function parameter 'bus'. +** (bcm1250_bus): Changed structure type to bus_driver_t. Changed members. +** (new_bcm1250_bus): Function renamed ... +** (bcm1250_bus_new): ... to this one. Changed parameter list to void (and function body updated). +** * src/bus/ixp425.c (ixp425_bus_printinfo): Added new function parameter 'bus'. +** (ixp425_bus): Changed structure type to bus_driver_t. Changed members. +** (new_ixp425_bus): Function renamed ... +** (ixp425_bus_new): ... to this one. Changed parameter list to void (and function body updated). +** * src/bus/pxa2x0.c (pxa2x0_bus_printinfo): Added new function parameter 'bus'. +** (pxa250_bus): Structure transformed ... +** (pxa2x0_bus): ... to this constant (changed type to bus_driver_t, changed members). +** (new_pxa250_bus): Function renamed ... +** (pxa2x0_bus_new): ... to this one. Changed parameter list to void (and function body updated). +** * src/bus/s3c4510x.c (s3c4510_bus_printinfo): Added new function parameter 'bus'. +** (s3c4510_bus): Changed structure type to bus_driver_t. Changed members. +** (new_s3c4510_bus): Function renamed ... +** (s3c4510_bus_new): ... to this one. Changed parameter list to void (and function body updated). +** * src/bus/sa1110.c (sa1110_bus_printinfo): Added new function parameter 'bus'. +** (sa1110_bus): Changed structure type to bus_driver_t. Changed members. +** (new_sa1110_bus): Function renamed ... +** (sa1110_bus_new): ... to this one. Changed parameter list to void (and function body updated). +** * src/bus/sh7727.c (sh7727_bus_printinfo): Added new function parameter 'bus'. +** (sh7727_bus): Changed structure type to bus_driver_t. Changed members. +** (new_sh7727_bus): Function renamed ... +** (sh7727_bus_new): ... to this one. Changed parameter list to void (and function body updated). +** * src/bus/sh7750r.c (sh7750r_bus_printinfo): Added new function parameter 'bus'. +** (sh7750r_bus): Changed structure type to bus_driver_t. Changed members. +** (new_sh7750r_bus): Function renamed ... +** (sh7750r_bus_new): ... to this one. Changed parameter list to void (and function body updated). +** * src/bus/sh7751r.c (sh7751r_bus_printinfo): Added new function parameter 'bus'. +** (sh7751r_bus): Changed structure type to bus_driver_t. Changed members. +** (new_sh7751r_bus): Function renamed ... +** (sh7751r_bus_new): ... to this one. Changed parameter list to void (and function body updated). +** +** * src/cmd/cable.c (cmd_cable_run): Replaced bus->free() call with bus_free(). +** * src/jtag.c (main): Ditto. +** +** * src/cmd/cmd.c (cmds): Added cmd_initbus. +** * src/cmd/detect.c (cmd_detect_run): Removed explicit bus driver detection. +** * src/cmd/initbus.c: New file. +** * src/cmd/Makefile.am (libcmd_a_SOURCES): Added initbus.c. +** +** * data/broadcom/bcm1250/bcm1250: Added 'initbus' command call. +** * data/hitachi/sh7727/sh7727: Ditto. +** * data/intel/ixp425/ixp425: Ditto. +** * data/intel/pxa250/pxa250: Ditto. +** * data/intel/pxa250/pxa250c0: Ditto. +** * data/intel/sa1110/sa1110: Ditto. +** * data/samsung/s3c4510b/s3c4510b: Ditto. +** ** Revision 1.3 2003/08/28 07:26:02 telka ** 2003-08-28 Marcel Telka ** diff --git a/jtag/src/bus/sa1110.c b/jtag/src/bus/sa1110.c index 03102efa..0527ce9a 100644 --- a/jtag/src/bus/sa1110.c +++ b/jtag/src/bus/sa1110.c @@ -36,6 +36,8 @@ #include "bus.h" #include "chain.h" #include "bssignal.h" +#include "jtag.h" +#include "buses.h" typedef struct { chain_t *chain; @@ -96,7 +98,7 @@ setup_data( bus_t *bus, uint32_t d ) } static void -sa1110_bus_printinfo( void ) +sa1110_bus_printinfo( bus_t *bus ) { int i; @@ -243,8 +245,13 @@ sa1110_bus_free( bus_t *bus ) free( bus ); } -static const bus_t sa1110_bus = { - NULL, +static bus_t *sa1110_bus_new( void ); + +const bus_driver_t sa1110_bus = { + "sa1110", + N_("Intel SA-1110 compatibile bus driver via BSR"), + sa1110_bus_new, + sa1110_bus_free, sa1110_bus_printinfo, sa1110_bus_prepare, sa1110_bus_area, @@ -252,27 +259,25 @@ static const bus_t sa1110_bus = { sa1110_bus_read_next, sa1110_bus_read_end, sa1110_bus_read, - sa1110_bus_write, - sa1110_bus_free + sa1110_bus_write }; -bus_t * -new_sa1110_bus( chain_t *chain, int pn ) +static bus_t * +sa1110_bus_new( void ) { bus_t *bus; char buff[10]; int i; int failed = 0; - if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; bus = malloc( sizeof (bus_t) ); if (!bus) return NULL; - memcpy( bus, &sa1110_bus, sizeof (bus_t) ); - + bus->driver = &sa1110_bus; bus->params = malloc( sizeof (bus_params_t) ); if (!bus->params) { free( bus ); @@ -280,7 +285,7 @@ new_sa1110_bus( chain_t *chain, int pn ) } CHAIN = chain; - PART = chain->parts->parts[pn]; + PART = chain->parts->parts[chain->active_part]; for (i = 0; i < 26; i++) { sprintf( buff, "A%d", i ); diff --git a/jtag/src/bus/sh7727.c b/jtag/src/bus/sh7727.c index 143f3f46..f26f9b8f 100644 --- a/jtag/src/bus/sh7727.c +++ b/jtag/src/bus/sh7727.c @@ -33,6 +33,8 @@ #include "bus.h" #include "chain.h" #include "bssignal.h" +#include "jtag.h" +#include "buses.h" typedef struct { chain_t *chain; @@ -97,7 +99,7 @@ setup_data( bus_t *bus, uint32_t d ) } static void -sh7727_bus_printinfo( void ) +sh7727_bus_printinfo( bus_t *bus ) { int i; @@ -275,8 +277,13 @@ sh7727_bus_free( bus_t *bus ) free( bus ); } -static const bus_t sh7727_bus = { - NULL, +static bus_t *sh7727_bus_new( void ); + +const bus_driver_t sh7727_bus = { + "sh7727", + N_("Hitachi SH7727 compatibile bus driver via BSR"), + sh7727_bus_new, + sh7727_bus_free, sh7727_bus_printinfo, sh7727_bus_prepare, sh7727_bus_area, @@ -284,27 +291,25 @@ static const bus_t sh7727_bus = { sh7727_bus_read_next, sh7727_bus_read_end, sh7727_bus_read, - sh7727_bus_write, - sh7727_bus_free + sh7727_bus_write }; -bus_t * -new_sh7727_bus( chain_t *chain, int pn ) +static bus_t * +sh7727_bus_new( void ) { bus_t *bus; char buff[10]; int i; int failed = 0; - if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; bus = malloc( sizeof (bus_t) ); if (!bus) return NULL; - memcpy( bus, &sh7727_bus, sizeof (bus_t) ); - + bus->driver = &sh7727_bus; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); @@ -312,7 +317,7 @@ new_sh7727_bus( chain_t *chain, int pn ) } CHAIN = chain; - PART = chain->parts->parts[pn]; + PART = chain->parts->parts[chain->active_part]; for (i = 0; i < 26; i++) { sprintf( buff, "A%d", i ); diff --git a/jtag/src/bus/sh7750r.c b/jtag/src/bus/sh7750r.c index e7ad330d..00dbf981 100644 --- a/jtag/src/bus/sh7750r.c +++ b/jtag/src/bus/sh7750r.c @@ -33,6 +33,8 @@ #include "bus.h" #include "chain.h" #include "bssignal.h" +#include "jtag.h" +#include "buses.h" typedef struct { chain_t *chain; @@ -89,7 +91,7 @@ setup_data( bus_t *bus, uint32_t d ) } static void -sh7750r_bus_printinfo( void ) +sh7750r_bus_printinfo( bus_t *bus ) { int i; @@ -257,8 +259,13 @@ sh7750r_bus_free( bus_t *bus ) free( bus ); } -static const bus_t sh7750r_bus = { - NULL, +static bus_t *sh7750r_bus_new( void ); + +const bus_driver_t sh7750r_bus = { + "sh7750r", + N_("Hitachi SH7750R compatibile bus driver via BSR"), + sh7750r_bus_new, + sh7750r_bus_free, sh7750r_bus_printinfo, sh7750r_bus_prepare, sh7750r_bus_area, @@ -266,27 +273,25 @@ static const bus_t sh7750r_bus = { sh7750r_bus_read_next, sh7750r_bus_read_end, sh7750r_bus_read, - sh7750r_bus_write, - sh7750r_bus_free + sh7750r_bus_write }; -bus_t * -new_sh7750r_bus( chain_t *chain, int pn ) +static bus_t * +sh7750r_bus_new( void ) { bus_t *bus; char buff[10]; int i; int failed = 0; - if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; bus = malloc( sizeof (bus_t) ); if (!bus) return NULL; - memcpy( bus, &sh7750r_bus, sizeof (bus_t) ); - + bus->driver = &sh7750r_bus; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); @@ -294,7 +299,7 @@ new_sh7750r_bus( chain_t *chain, int pn ) } CHAIN = chain; - PART = chain->parts->parts[pn]; + PART = chain->parts->parts[chain->active_part]; for (i = 0; i < 26; i++) { sprintf( buff, "A%d", i ); diff --git a/jtag/src/bus/sh7751r.c b/jtag/src/bus/sh7751r.c index 8a95960d..5056368a 100644 --- a/jtag/src/bus/sh7751r.c +++ b/jtag/src/bus/sh7751r.c @@ -33,6 +33,8 @@ #include "bus.h" #include "chain.h" #include "bssignal.h" +#include "jtag.h" +#include "buses.h" typedef struct { chain_t *chain; @@ -87,7 +89,7 @@ setup_data( bus_t *bus, uint32_t d ) } static void -sh7751r_bus_printinfo( void ) +sh7751r_bus_printinfo( bus_t *bus ) { int i; @@ -250,8 +252,13 @@ sh7751r_bus_free( bus_t *bus ) free( bus ); } -static const bus_t sh7751r_bus = { - NULL, +static bus_t *sh7751r_bus_new( void ); + +const bus_driver_t sh7751r_bus = { + "sh7751r", + N_("Hitachi SH7751R compatibile bus driver via BSR"), + sh7751r_bus_new, + sh7751r_bus_free, sh7751r_bus_printinfo, sh7751r_bus_prepare, sh7751r_bus_area, @@ -259,27 +266,25 @@ static const bus_t sh7751r_bus = { sh7751r_bus_read_next, sh7751r_bus_read_end, sh7751r_bus_read, - sh7751r_bus_write, - sh7751r_bus_free + sh7751r_bus_write }; -bus_t * -new_sh7751r_bus( chain_t *chain, int pn ) +static bus_t * +sh7751r_bus_new( void ) { bus_t *bus; char buff[10]; int i; int failed = 0; - if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; bus = malloc( sizeof (bus_t) ); if (!bus) return NULL; - memcpy( bus, &sh7751r_bus, sizeof (bus_t) ); - + bus->driver = &sh7751r_bus; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); @@ -287,7 +292,7 @@ new_sh7751r_bus( chain_t *chain, int pn ) } CHAIN = chain; - PART = chain->parts->parts[pn]; + PART = chain->parts->parts[chain->active_part]; for (i = 0; i < 26; i++) { sprintf( buff, "A%d", i ); diff --git a/jtag/src/cmd/Makefile.am b/jtag/src/cmd/Makefile.am index 1650b07f..e2ab6a7b 100644 --- a/jtag/src/cmd/Makefile.am +++ b/jtag/src/cmd/Makefile.am @@ -33,6 +33,7 @@ libcmd_a_SOURCES = \ signal.c \ bit.c \ register.c \ + initbus.c \ print.c \ part.c \ bus.c \ diff --git a/jtag/src/cmd/cable.c b/jtag/src/cmd/cable.c index ec00a804..9b62a539 100644 --- a/jtag/src/cmd/cable.c +++ b/jtag/src/cmd/cable.c @@ -55,7 +55,7 @@ cmd_cable_run( char *params[] ) } if (bus) { - bus->free( bus ); + bus_free( bus ); bus = NULL; } chain_disconnect( chain ); diff --git a/jtag/src/cmd/cmd.c b/jtag/src/cmd/cmd.c index 8354340a..89ac848b 100644 --- a/jtag/src/cmd/cmd.c +++ b/jtag/src/cmd/cmd.c @@ -40,6 +40,7 @@ extern cmd_t cmd_detect; extern cmd_t cmd_signal; extern cmd_t cmd_bit; extern cmd_t cmd_register; +extern const cmd_t cmd_initbus; extern cmd_t cmd_print; extern cmd_t cmd_part; extern cmd_t cmd_bus; @@ -68,6 +69,7 @@ const cmd_t *cmds[] = { &cmd_signal, &cmd_bit, &cmd_register, + &cmd_initbus, &cmd_print, &cmd_part, &cmd_bus, diff --git a/jtag/src/cmd/detect.c b/jtag/src/cmd/detect.c index 65d162d3..879c0067 100644 --- a/jtag/src/cmd/detect.c +++ b/jtag/src/cmd/detect.c @@ -36,8 +36,6 @@ static int cmd_detect_run( char *params[] ) { - int i; - if (cmd_params( params ) != 1) return -1; @@ -60,21 +58,6 @@ cmd_detect_run( char *params[] ) parts_set_instruction( chain->parts, "BYPASS" ); chain_shift_instructions( chain ); - for (i = 0; i < chain->parts->len; i++) { - if (strcmp( chain->parts->parts[i]->part, "SA1110" ) == 0) - buses_add( new_sa1110_bus( chain, i ) ); - if (strcmp( chain->parts->parts[i]->part, "PXA250" ) == 0) - buses_add( new_pxa250_bus( chain, i ) ); - if (strcmp( chain->parts->parts[i]->part, "IXP425" ) == 0) - buses_add( new_ixp425_bus( chain, i ) ); - if (strcmp( chain->parts->parts[i]->part, "SH7727" ) == 0) - buses_add( new_sh7727_bus( chain, i ) ); - if (strcmp( chain->parts->parts[i]->part, "SH7750R" ) == 0) - buses_add( new_sh7750r_bus( chain, i ) ); - if (strcmp( chain->parts->parts[i]->part, "BCM1250" ) == 0) - buses_add( new_bcm1250_bus( chain, i ) ); - } - return 1; } diff --git a/jtag/src/cmd/initbus.c b/jtag/src/cmd/initbus.c new file mode 100644 index 00000000..27fbf378 --- /dev/null +++ b/jtag/src/cmd/initbus.c @@ -0,0 +1,95 @@ +/* + * $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 , 2003. + * + */ + +#include "sysdep.h" + +#include +#include +#include + +#include "cmd.h" +#include "jtag.h" + +static int +cmd_initbus_run( char *params[] ) +{ + int i; + + if (cmd_params( params ) != 2) + 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"), "initbus" ); + return 1; + } + + for (i = 0; bus_drivers[i] != NULL; i++) { + if (strcmp( bus_drivers[i]->name, params[1] ) == 0) { + bus_t *bus = bus_drivers[i]->new_bus(); + if (bus == NULL) { + printf( _("bus initialization failed!\n") ); + return 1; + } + buses_add( bus ); + return 1; + } + } + + printf( _("Unknown bus: %s\n"), params[1] ); + + return 1; +} + +static void +cmd_initbus_help( void ) +{ + int i; + + printf( _( + "Usage: %s BUSNAME\n" + "Initialize new bus driver for active part.\n" + "\n" + "BUSNAME Name of the bus\n" + "\n" + "List of available buses:\n" + ), "initbus" ); + + for (i = 0; bus_drivers[i] != NULL; i++) + printf( _("%-10s %s\n"), bus_drivers[i]->name, bus_drivers[i]->description ); +} + +const cmd_t cmd_initbus = { + "initbus", + N_("initialize bus driver for active part"), + cmd_initbus_help, + cmd_initbus_run +}; diff --git a/jtag/src/jtag.c b/jtag/src/jtag.c index 913135dd..e2f7bf52 100644 --- a/jtag/src/jtag.c +++ b/jtag/src/jtag.c @@ -302,7 +302,7 @@ main( int argc, const char **argv ) } if (bus) { - bus->free( bus ); + bus_free( bus ); bus = NULL; } chain_free( chain );