From 6edc1f842dc2f4ffc6f63e4c06e31abfe3a11335 Mon Sep 17 00:00:00 2001 From: Jie Zhang Date: Wed, 2 Jul 2008 00:32:52 +0000 Subject: [PATCH] [ 2007630 ] Pass driver to new_bus git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1292 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 60 +++++++++++++++ jtag/include/bus_driver.h | 7 +- jtag/src/bus/au1500.c | 4 +- jtag/src/bus/avr32.c | 4 +- jtag/src/bus/bcm1250.c | 4 +- jtag/src/bus/bf533_ezkit.c | 4 +- jtag/src/bus/bf533_stamp.c | 4 +- jtag/src/bus/bf537_stamp.c | 138 ++++++----------------------------- jtag/src/bus/bf548_ezkit.c | 4 +- jtag/src/bus/bf561_ezkit.c | 4 +- jtag/src/bus/ejtag.c | 4 +- jtag/src/bus/fjmem.c | 4 +- jtag/src/bus/h7202.c | 4 +- jtag/src/bus/ixp425.c | 4 +- jtag/src/bus/jopcyc.c | 4 +- jtag/src/bus/lh7a400.c | 4 +- jtag/src/bus/mpc5200.c | 4 +- jtag/src/bus/mpc824x.c | 4 +- jtag/src/bus/ppc405ep.c | 4 +- jtag/src/bus/ppc440gx_ebc8.c | 4 +- jtag/src/bus/prototype.c | 4 +- jtag/src/bus/pxa2x0.c | 126 ++++++-------------------------- jtag/src/bus/s3c4510x.c | 4 +- jtag/src/bus/sa1110.c | 4 +- jtag/src/bus/sh7727.c | 4 +- jtag/src/bus/sh7750r.c | 4 +- jtag/src/bus/sh7751r.c | 4 +- jtag/src/bus/sharc21065l.c | 4 +- jtag/src/bus/slsup3.c | 4 +- jtag/src/bus/tx4925.c | 4 +- jtag/src/bus/zefant-xs3.c | 6 +- jtag/src/cmd/initbus.c | 2 +- 32 files changed, 168 insertions(+), 275 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index ffd69d61..397a17c3 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,63 @@ +2008-07-02 Jie Zhang + + * include/bus_driver.h (struct bus_driver): Add driver argument + to new_bus. + * src/cmd/initbus.c (cmd_initbus_run): Pass driver to new_bus. + * src/bus/bf548_ezkit.c (bf548_ezkit_bus_new): Add driver + argument and use it. + * src/bus/fjmem.c (fjmem_bus_new): Likewise. + * src/bus/ppc405ep.c (ppc405ep_bus_new): Likewise. + * src/bus/sh7727.c (sh7727_bus_new): Likewise. + * src/bus/prototype.c (prototype_bus_new): Likewise. + * src/bus/sa1110.c (sa1110_bus_new): Likewise. + * src/bus/ppc440gx_ebc8.c (ppc440gx_ebc8_bus_new): Likewise. + * src/bus/sh7750r.c (sh7750r_bus_new): Likewise. + * src/bus/tx4925.c (tx4925_bus_new): Likewise. + * src/bus/bf533_stamp.c (bf533_stamp_bus_new): Likewise. + * src/bus/bf533_ezkit.c (bf533_ezkit_bus_new): Likewise. + * src/bus/ixp425.c (ixp425_bus_new): Likewise. + * src/bus/avr32.c (avr32_bus_new): Likewise. + * src/bus/zefant-xs3.c (zefant_xs3_bus_new): Likewise. + * src/bus/h7202.c (h7202_bus_new): Likewise. + * src/bus/mpc824x.c (mpc824x_bus_new): Likewise. + * src/bus/bcm1250.c (bcm1250_bus_new): Likewise. + * src/bus/sharc21065l.c (sharc_21065L_bus_new): Likewise. + * src/bus/au1500.c (au1500_bus_new): Likewise. + * src/bus/lh7a400.c (lh7a400_bus_new): Likewise. + * src/bus/sh7751r.c (sh7751r_bus_new): Likewise. + * src/bus/mpc5200.c (mpc5200_bus_new): Likewise. + * src/bus/jopcyc.c (jopcyc_bus_new): Likewise. + * src/bus/bf561_ezkit.c (bf561_ezkit_bus_new): Likewise. + * src/bus/slsup3.c (slsup3_bus_new): Likewise. + * src/bus/s3c4510x.c (s3c4510_bus_new): Likewise. + * src/bus/ejtag.c (ejtag_bus_new): Likewise. + * src/bus/pxa2x0.c (pxa2xx_bus_new_common): Remove. + (pxa2xx_bus_new): New. + (pxa2x0_bus_new): Remove. + (pxa27x_bus_new): Remove. + (pxa2xx_bus_printinfo): New. + (pxa2x0_bus_printinfo): Remove. + (pxa27x_bus_printinfo): Remove. + (bus_driver_t pxa2x0_bus): Replace pxa2x0_bus_new with + pxa2xx_bus_new. Replace pxa2x0_bus_printinfo with + pxa2xx_bus_printinfo. + (bus_driver_t pxa27x_bus): Replace pxa27x_bus_new with + pxa2xx_bus_new. Replace pxa27x_bus_printinfo with + pxa2xx_bus_printinfo. + * src/bus/bf537_stamp.c (bf537_stamp_bus_new_1): Rename + to ... + (bf537_stamp_bus_new): ... this. And use the new driver + argument. + (bf537_ezkit_bus_new): Remove. + (bf527_ezkit_bus_new): Remove. + (bf537_stamp_bus_printinfo): Use description in bus driver. + (bf537_ezkit_bus_printinfo): Remove. + (bf527_ezkit_bus_printinfo): Remove. + (BF537_STAMP_BUS_FUNCTIONS): Define. + (bus_driver_t bf537_stamp_bus): Use BF537_STAMP_BUS_FUNCTIONS. + (bus_driver_t bf537_ezkit_bus): Likewise. + (bus_driver_t bf527_ezkit_bus): Likewise. + 2008-06-28 Kolja Waschk * data/sigma/smp8634/smp8634, data/sigma/smp8634/STEPPINGS, diff --git a/jtag/include/bus_driver.h b/jtag/include/bus_driver.h index 1214d41d..2ea19bbb 100644 --- a/jtag/include/bus_driver.h +++ b/jtag/include/bus_driver.h @@ -47,11 +47,12 @@ typedef struct { } bus_area_t; typedef struct bus bus_t; +typedef struct bus_driver bus_driver_t; -typedef struct bus_driver { +struct bus_driver { const char *name; const char *description; - bus_t *(*new_bus)( chain_t *chain, char *cmd_params[] ); + bus_t *(*new_bus)( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ); void (*free_bus)( bus_t *bus ); void (*printinfo)( bus_t *bus ); void (*prepare)( bus_t *bus ); @@ -62,7 +63,7 @@ typedef struct bus_driver { uint32_t (*read)( bus_t *bus, uint32_t adr ); void (*write)( bus_t *bus, uint32_t adr, uint32_t data ); int (*init) (bus_t *bus); -} bus_driver_t; +}; struct bus { chain_t *chain; diff --git a/jtag/src/bus/au1500.c b/jtag/src/bus/au1500.c index d0340f69..ccf6bb73 100644 --- a/jtag/src/bus/au1500.c +++ b/jtag/src/bus/au1500.c @@ -59,7 +59,7 @@ typedef struct{ * bus->driver->(*new_bus) * */ -static bus_t *au1500_bus_new( chain_t *chain, char *cmd_params[] ) +static bus_t *au1500_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -71,7 +71,7 @@ static bus_t *au1500_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &au1500_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof(bus_params_t) ); if (!bus->params){ free(bus); diff --git a/jtag/src/bus/avr32.c b/jtag/src/bus/avr32.c index b18c5138..b04b4d8a 100644 --- a/jtag/src/bus/avr32.c +++ b/jtag/src/bus/avr32.c @@ -475,7 +475,7 @@ check_instruction (part_t * part, const char *instr) * */ static bus_t * -avr32_bus_new (chain_t * chain, char *cmd_params[]) +avr32_bus_new (chain_t * chain, const bus_driver_t *driver, char *cmd_params[]) { bus_t *bus; part_t *part; @@ -541,7 +541,7 @@ avr32_bus_new (chain_t * chain, char *cmd_params[]) if (!bus) return NULL; - bus->driver = &avr32_bus_driver; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { diff --git a/jtag/src/bus/bcm1250.c b/jtag/src/bus/bcm1250.c index 66c8c4f1..625e85a9 100644 --- a/jtag/src/bus/bcm1250.c +++ b/jtag/src/bus/bcm1250.c @@ -58,7 +58,7 @@ typedef struct { * */ static bus_t * -bcm1250_bus_new( chain_t *chain, char *cmd_params[] ) +bcm1250_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -70,7 +70,7 @@ bcm1250_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = & bcm1250_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/bf533_ezkit.c b/jtag/src/bus/bf533_ezkit.c index 389cf14a..d7188ef8 100644 --- a/jtag/src/bus/bf533_ezkit.c +++ b/jtag/src/bus/bf533_ezkit.c @@ -66,7 +66,7 @@ typedef struct { * */ static bus_t * -bf533_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) +bf533_ezkit_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -78,7 +78,7 @@ bf533_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &bf533_ezkit_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/bf533_stamp.c b/jtag/src/bus/bf533_stamp.c index 886475f2..e9ca9a6e 100644 --- a/jtag/src/bus/bf533_stamp.c +++ b/jtag/src/bus/bf533_stamp.c @@ -66,7 +66,7 @@ typedef struct { * */ static bus_t * -bf533_stamp_bus_new( chain_t *chain, char *cmd_params[] ) +bf533_stamp_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -78,7 +78,7 @@ bf533_stamp_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &bf533_stamp_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/bf537_stamp.c b/jtag/src/bus/bf537_stamp.c index a69cf9f7..6824def5 100644 --- a/jtag/src/bus/bf537_stamp.c +++ b/jtag/src/bus/bf537_stamp.c @@ -66,7 +66,7 @@ typedef struct { * */ static bus_t * -bf537_stamp_bus_new_1( chain_t *chain, char *cmd_params[] ) +bf537_stamp_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -78,6 +78,7 @@ bf537_stamp_bus_new_1( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); @@ -286,8 +287,6 @@ bf537_stamp_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) part_t *p = PART; chain_t *chain = CHAIN; -// printf("Writing %04X to %08X...\n", data, adr); - select_flash( bus ); part_set_signal( p, ARE, 1, 1 ); @@ -303,22 +302,6 @@ bf537_stamp_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -#ifdef ENABLE_BUS_BF537_STAMP - -/** - * bus->driver->(*new_bus) - * - */ -static bus_t * -bf537_stamp_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - bus = bf537_stamp_bus_new_1 (chain, cmd_params); - if (bus) - bus->driver = &bf537_stamp_bus; - return bus; -} - /** * bus->driver->(*printinfo) * @@ -331,121 +314,48 @@ bf537_stamp_bus_printinfo( bus_t *bus ) for (i = 0; i < CHAIN->parts->len; i++) if (PART == CHAIN->parts->parts[i]) break; - printf( _("Blackfin BF537 Stamp compatible bus driver via BSR (JTAG part No. %d)\n"), i ); + printf( _("%s (JTAG part No. %d)\n"), bus->driver->description, i ); } +#define BF537_STAMP_BUS_FUNCTIONS \ + bf537_stamp_bus_new, \ + generic_bus_free, \ + bf537_stamp_bus_printinfo, \ + generic_bus_prepare_extest, \ + bf537_stamp_bus_area, \ + bf537_stamp_bus_read_start, \ + bf537_stamp_bus_read_next, \ + bf537_stamp_bus_read_end, \ + generic_bus_read, \ + bf537_stamp_bus_write, \ + generic_bus_no_init + +#ifdef ENABLE_BUS_BF537_STAMP + const bus_driver_t bf537_stamp_bus = { "bf537_stamp", - N_("Blackfin BF537 Stamp board bus driver"), - bf537_stamp_bus_new, - generic_bus_free, - bf537_stamp_bus_printinfo, - generic_bus_prepare_extest, - bf537_stamp_bus_area, - bf537_stamp_bus_read_start, - bf537_stamp_bus_read_next, - bf537_stamp_bus_read_end, - generic_bus_read, - bf537_stamp_bus_write, - generic_bus_no_init + N_("Blackfin BF537 Stamp board bus driver via BSR"), + BF537_STAMP_BUS_FUNCTIONS }; #endif /* #ifdef ENABLE_BUS_BF537_STAMP */ #ifdef ENABLE_BUS_BF537_EZKIT -/** - * bus->driver->(*new_bus) - * - */ -static bus_t * -bf537_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - bus = bf537_stamp_bus_new_1 (chain, cmd_params); - if (bus) - bus->driver = &bf537_ezkit_bus; - return bus; -} - -/** - * bus->driver->(*printinfo) - * - */ -static void -bf537_ezkit_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Blackfin BF537 EZ-KIT compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - const bus_driver_t bf537_ezkit_bus = { "bf537_ezkit", - N_("Blackfin BF537 EZ-KIT board bus driver"), - bf537_ezkit_bus_new, - generic_bus_free, - bf537_ezkit_bus_printinfo, - generic_bus_prepare_extest, - bf537_stamp_bus_area, - bf537_stamp_bus_read_start, - bf537_stamp_bus_read_next, - bf537_stamp_bus_read_end, - generic_bus_read, - bf537_stamp_bus_write, - generic_bus_no_init + N_("Blackfin BF537 EZ-KIT board bus driver via BSR"), + BF537_STAMP_BUS_FUNCTIONS }; #endif /* #ifdef ENABLE_BUS_BF537_EZKIT */ #ifdef ENABLE_BUS_BF527_EZKIT -/** - * bus->driver->(*new_bus) - * - */ -static bus_t * -bf527_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - bus = bf537_stamp_bus_new_1 (chain, cmd_params); - if (bus) - bus->driver = &bf527_ezkit_bus; - return bus; -} - -/** - * bus->driver->(*printinfo) - * - */ -static void -bf527_ezkit_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Blackfin BF527 EZ-KIT compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - const bus_driver_t bf527_ezkit_bus = { "bf527_ezkit", - N_("Blackfin BF527 EZ-KIT board bus driver"), - bf527_ezkit_bus_new, - generic_bus_free, - bf527_ezkit_bus_printinfo, - generic_bus_prepare_extest, - bf537_stamp_bus_area, - bf537_stamp_bus_read_start, - bf537_stamp_bus_read_next, - bf537_stamp_bus_read_end, - generic_bus_read, - bf537_stamp_bus_write, - generic_bus_no_init + N_("Blackfin BF527 EZ-KIT board bus driver via BSR"), + BF537_STAMP_BUS_FUNCTIONS }; #endif /* #ifdef ENABLE_BUS_BF527_EZKIT */ diff --git a/jtag/src/bus/bf548_ezkit.c b/jtag/src/bus/bf548_ezkit.c index a3b82072..91228207 100644 --- a/jtag/src/bus/bf548_ezkit.c +++ b/jtag/src/bus/bf548_ezkit.c @@ -61,7 +61,7 @@ typedef struct { * */ static bus_t * -bf548_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) +bf548_ezkit_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -73,7 +73,7 @@ bf548_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &bf548_ezkit_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/bf561_ezkit.c b/jtag/src/bus/bf561_ezkit.c index 5a44720a..03c3d013 100644 --- a/jtag/src/bus/bf561_ezkit.c +++ b/jtag/src/bus/bf561_ezkit.c @@ -66,7 +66,7 @@ typedef struct { * */ static bus_t * -bf561_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) +bf561_ezkit_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -78,7 +78,7 @@ bf561_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &bf561_ezkit_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/ejtag.c b/jtag/src/bus/ejtag.c index cfaea719..273cd48c 100644 --- a/jtag/src/bus/ejtag.c +++ b/jtag/src/bus/ejtag.c @@ -72,7 +72,7 @@ typedef struct { * */ static bus_t * -ejtag_bus_new( chain_t *chain, char *cmd_params[] ) +ejtag_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; @@ -80,7 +80,7 @@ ejtag_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &ejtag_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/fjmem.c b/jtag/src/bus/fjmem.c index 2ed60a55..bc096df0 100644 --- a/jtag/src/bus/fjmem.c +++ b/jtag/src/bus/fjmem.c @@ -347,7 +347,7 @@ fjmem_query_blocks( chain_t *chain, part_t *part, bus_t *bus ) * */ static bus_t * -fjmem_bus_new( chain_t *chain, char *params[] ) +fjmem_bus_new( chain_t *chain, const bus_driver_t *driver, char *params[] ) { bus_t *bus = NULL; int failed = 0; @@ -392,7 +392,7 @@ fjmem_bus_new( chain_t *chain, char *params[] ) if (!bus) return NULL; - bus->driver = &fjmem_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/h7202.c b/jtag/src/bus/h7202.c index d25706bc..ce0b309b 100644 --- a/jtag/src/bus/h7202.c +++ b/jtag/src/bus/h7202.c @@ -56,7 +56,7 @@ typedef struct { * */ static bus_t * -h7202_bus_new( chain_t *chain, char *cmd_params[] ) +h7202_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -68,7 +68,7 @@ h7202_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &h7202_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/ixp425.c b/jtag/src/bus/ixp425.c index 630f807b..551ddb92 100644 --- a/jtag/src/bus/ixp425.c +++ b/jtag/src/bus/ixp425.c @@ -56,7 +56,7 @@ typedef struct { * */ static bus_t * -ixp425_bus_new( chain_t *chain, char *cmd_params[] ) +ixp425_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -68,7 +68,7 @@ ixp425_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &ixp425_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/jopcyc.c b/jtag/src/bus/jopcyc.c index 362b9e80..c15eca67 100644 --- a/jtag/src/bus/jopcyc.c +++ b/jtag/src/bus/jopcyc.c @@ -134,7 +134,7 @@ typedef struct { * */ static bus_t * -jopcyc_bus_new( chain_t *chain, char *cmd_params[] ) +jopcyc_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -145,7 +145,7 @@ jopcyc_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &jopcyc_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/lh7a400.c b/jtag/src/bus/lh7a400.c index 1d00f902..93b70b65 100644 --- a/jtag/src/bus/lh7a400.c +++ b/jtag/src/bus/lh7a400.c @@ -72,7 +72,7 @@ typedef struct { * */ static bus_t * -lh7a400_bus_new( chain_t *chain, char *cmd_params[] ) +lh7a400_bus_new( chain_t *chain, const const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -84,7 +84,7 @@ lh7a400_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &lh7a400_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/mpc5200.c b/jtag/src/bus/mpc5200.c index 86bb34e6..d35df19a 100644 --- a/jtag/src/bus/mpc5200.c +++ b/jtag/src/bus/mpc5200.c @@ -61,7 +61,7 @@ typedef struct { * */ static bus_t * -mpc5200_bus_new( chain_t *chain, char *cmd_params[] ) +mpc5200_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -73,7 +73,7 @@ mpc5200_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &mpc5200_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/mpc824x.c b/jtag/src/bus/mpc824x.c index b6238132..c356b10b 100644 --- a/jtag/src/bus/mpc824x.c +++ b/jtag/src/bus/mpc824x.c @@ -71,7 +71,7 @@ char dbgData = 0; * */ static bus_t * -mpc824x_bus_new( chain_t *chain, char *cmd_params[] ) +mpc824x_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -145,7 +145,7 @@ mpc824x_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &mpc824x_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/ppc405ep.c b/jtag/src/bus/ppc405ep.c index 70c03a11..645f8770 100644 --- a/jtag/src/bus/ppc405ep.c +++ b/jtag/src/bus/ppc405ep.c @@ -54,7 +54,7 @@ typedef struct { * */ static bus_t * -ppc405ep_bus_new( chain_t *chain, char *cmd_params[] ) +ppc405ep_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -66,7 +66,7 @@ ppc405ep_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &ppc405ep_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/ppc440gx_ebc8.c b/jtag/src/bus/ppc440gx_ebc8.c index f337cb91..4ef2d93a 100644 --- a/jtag/src/bus/ppc440gx_ebc8.c +++ b/jtag/src/bus/ppc440gx_ebc8.c @@ -56,7 +56,7 @@ typedef struct { * */ static bus_t * -ppc440gx_ebc8_bus_new( chain_t *chain, char *cmd_params[] ) +ppc440gx_ebc8_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -68,7 +68,7 @@ ppc440gx_ebc8_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &ppc440gx_ebc8_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/prototype.c b/jtag/src/bus/prototype.c index 7d8454ab..334bd92c 100644 --- a/jtag/src/bus/prototype.c +++ b/jtag/src/bus/prototype.c @@ -89,7 +89,7 @@ prototype_bus_signal_parse( char *str, char *fmt, int *inst ) * */ static bus_t * -prototype_bus_new( chain_t *chain, char *cmd_params[] ) +prototype_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; signal_t *sig; @@ -102,7 +102,7 @@ prototype_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &prototype_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/pxa2x0.c b/jtag/src/bus/pxa2x0.c index cc6f79fb..9cb1561b 100644 --- a/jtag/src/bus/pxa2x0.c +++ b/jtag/src/bus/pxa2x0.c @@ -133,26 +133,28 @@ typedef struct { #define INITED ((bus_params_t *) bus->params)->inited -/* +/** * bus->driver->(*new_bus) * */ -static int -pxa2xx_bus_new_common(bus_t * bus) +static bus_t * +pxa2xx_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { part_t *part; + bus_t *bus; ncs_map_entry* ncs_map = NULL; char buff[10]; int i; int failed = 0; -#ifdef PREPATCHNEVER - bus_t *bus; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; - bus->driver = &pxa2x0_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); @@ -160,9 +162,16 @@ pxa2xx_bus_new_common(bus_t * bus) } CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; -#endif - part = PART; + PART = part = chain->parts->parts[chain->active_part]; + if (strcmp (driver->name, "pxa2x0") == 0) + PROC = PROC_PXA25x; + else if (strcmp (driver->name, "pxa27x") == 0) + PROC = PROC_PXA27x; + else { + free (bus->params); + free (bus); + return NULL; + } for (i = 0; i < 26; i++) { sprintf( buff, "MA[%d]", i ); @@ -208,39 +217,6 @@ pxa2xx_bus_new_common(bus_t * bus) failed |= generic_bus_attach_sig( part, &(nSDCAS), "nSDCAS" ); - return failed; -} - -/** - * bus->driver->(*new_bus) - * - */ -static bus_t * -pxa2x0_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &pxa2x0_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - PROC = PROC_PXA25x; - - failed = pxa2xx_bus_new_common(bus); - if (failed) { free( bus->params ); free( bus ); @@ -250,73 +226,19 @@ pxa2x0_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } -/** - * bus->driver->(*new_bus) - * - */ -static bus_t * -pxa27x_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &pxa27x_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - PROC = PROC_PXA27x; - - failed = pxa2xx_bus_new_common(bus); - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - -/** - * bus->driver->(*printinfo) - * - */ -static void -pxa2x0_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Intel PXA2x0 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - /** * bus->driver->(*printinfo) * */ static void -pxa27x_bus_printinfo( bus_t *bus ) +pxa2xx_bus_printinfo( bus_t *bus ) { int i; for (i = 0; i < CHAIN->parts->len; i++) if (PART == CHAIN->parts->parts[i]) break; - printf( _("Intel PXA27x compatible bus driver via BSR (JTAG part No. %d)\n"), i ); + printf( _("%s (JTAG part No. %d)\n"), bus->driver->description, i ); } /** @@ -769,9 +691,9 @@ pxa2xx_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) const bus_driver_t pxa2x0_bus = { "pxa2x0", N_("Intel PXA2x0 compatible bus driver via BSR"), - pxa2x0_bus_new, + pxa2xx_bus_new, generic_bus_free, - pxa2x0_bus_printinfo, + pxa2xx_bus_printinfo, generic_bus_prepare_extest, pxa2xx_bus_area, pxa2xx_bus_read_start, @@ -785,9 +707,9 @@ const bus_driver_t pxa2x0_bus = { const bus_driver_t pxa27x_bus = { "pxa27x", N_("Intel PXA27x compatible bus driver via BSR"), - pxa27x_bus_new, + pxa2xx_bus_new, generic_bus_free, - pxa27x_bus_printinfo, + pxa2xx_bus_printinfo, generic_bus_prepare_extest, pxa27x_bus_area, pxa2xx_bus_read_start, diff --git a/jtag/src/bus/s3c4510x.c b/jtag/src/bus/s3c4510x.c index e62902b8..9c0ce9c9 100644 --- a/jtag/src/bus/s3c4510x.c +++ b/jtag/src/bus/s3c4510x.c @@ -101,7 +101,7 @@ typedef struct { * */ static bus_t * -s3c4510_bus_new( chain_t *chain, char *cmd_params[] ) +s3c4510_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -113,7 +113,7 @@ s3c4510_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &s3c4510_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/sa1110.c b/jtag/src/bus/sa1110.c index 89fe1552..4e2318d6 100644 --- a/jtag/src/bus/sa1110.c +++ b/jtag/src/bus/sa1110.c @@ -61,7 +61,7 @@ typedef struct { * */ static bus_t * -sa1110_bus_new( chain_t *chain, char *cmd_params[] ) +sa1110_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -73,7 +73,7 @@ sa1110_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &sa1110_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/sh7727.c b/jtag/src/bus/sh7727.c index 696fba71..8de79bd1 100644 --- a/jtag/src/bus/sh7727.c +++ b/jtag/src/bus/sh7727.c @@ -62,7 +62,7 @@ typedef struct { * */ static bus_t * -sh7727_bus_new( chain_t *chain, char *cmd_params[] ) +sh7727_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -74,7 +74,7 @@ sh7727_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &sh7727_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/sh7750r.c b/jtag/src/bus/sh7750r.c index ca35dce8..e4f7e4a5 100644 --- a/jtag/src/bus/sh7750r.c +++ b/jtag/src/bus/sh7750r.c @@ -62,7 +62,7 @@ typedef struct { * */ static bus_t * -sh7750r_bus_new( chain_t *chain, char *cmd_params[] ) +sh7750r_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -74,7 +74,7 @@ sh7750r_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &sh7750r_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/sh7751r.c b/jtag/src/bus/sh7751r.c index 3480d09a..ba4defb8 100644 --- a/jtag/src/bus/sh7751r.c +++ b/jtag/src/bus/sh7751r.c @@ -60,7 +60,7 @@ typedef struct { * */ static bus_t * -sh7751r_bus_new( chain_t *chain, char *cmd_params[] ) +sh7751r_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -72,7 +72,7 @@ sh7751r_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &sh7751r_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/sharc21065l.c b/jtag/src/bus/sharc21065l.c index 1a4dcab5..288c4e51 100644 --- a/jtag/src/bus/sharc21065l.c +++ b/jtag/src/bus/sharc21065l.c @@ -62,7 +62,7 @@ typedef struct { * bus->driver->(*new_bus) * */ -static bus_t *sharc_21065L_bus_new( chain_t *chain, char *cmd_params[] ) +static bus_t *sharc_21065L_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -74,7 +74,7 @@ static bus_t *sharc_21065L_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &sharc_21065L_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/slsup3.c b/jtag/src/bus/slsup3.c index 011336d3..012c0af6 100644 --- a/jtag/src/bus/slsup3.c +++ b/jtag/src/bus/slsup3.c @@ -89,7 +89,7 @@ typedef struct { * */ static bus_t * -slsup3_bus_new( chain_t *chain, char *cmd_params[] ) +slsup3_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -101,7 +101,7 @@ slsup3_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &slsup3_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/tx4925.c b/jtag/src/bus/tx4925.c index 8ac01a75..6ef0b70f 100644 --- a/jtag/src/bus/tx4925.c +++ b/jtag/src/bus/tx4925.c @@ -70,7 +70,7 @@ typedef struct { * */ static bus_t * -tx4925_bus_new( chain_t *chain, char *cmd_params[] ) +tx4925_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -82,7 +82,7 @@ tx4925_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &tx4925_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { free( bus ); diff --git a/jtag/src/bus/zefant-xs3.c b/jtag/src/bus/zefant-xs3.c index 8fde679d..dc381cd5 100644 --- a/jtag/src/bus/zefant-xs3.c +++ b/jtag/src/bus/zefant-xs3.c @@ -152,7 +152,7 @@ typedef struct { * */ static bus_t * -zefant_xs3_bus_new( chain_t *chain, char *cmd_params[] ) +zefant_xs3_bus_new( chain_t *chain, const bus_driver_t *driver, char *cmd_params[] ) { bus_t *bus; part_t *part; @@ -164,10 +164,10 @@ zefant_xs3_bus_new( chain_t *chain, char *cmd_params[] ) if (!bus) return NULL; - bus->driver = &zefant_xs3_bus; + bus->driver = driver; bus->params = calloc( 1, sizeof (bus_params_t) ); if (!bus->params) { - free( bus ); + free( bus );\ return NULL; } diff --git a/jtag/src/cmd/initbus.c b/jtag/src/cmd/initbus.c index d4324e91..ef12227f 100644 --- a/jtag/src/cmd/initbus.c +++ b/jtag/src/cmd/initbus.c @@ -54,7 +54,7 @@ cmd_initbus_run( chain_t *chain, char *params[] ) for (i = 0; bus_drivers[i] != NULL; i++) { if (strcasecmp( bus_drivers[i]->name, params[1] ) == 0) { - bus_t *bus = bus_drivers[i]->new_bus( chain, params ); + bus_t *bus = bus_drivers[i]->new_bus( chain, bus_drivers[i], params ); if (bus == NULL) { printf( _("bus alloc/attach failed!\n") ); return 1;