[ 1984813 ] Bus driver cleanup

Separate (*init) and (*prepare) functions
(Hartley Sweeten)


git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1288 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Arnim Läuger 17 years ago
parent 9898081986
commit 684ef2f9f7

@ -1,3 +1,20 @@
2008-06-27 Arnim Laeuger <arniml@users.sourceforge.net>
* UrJTAG.txt: update of bus driver init() function
* include/bus_driver.h, src/cmd/initbus.c, src/bus/bf548_ezkit.c,
src/bus/fjmem.c, src/bus/ppc405ep.c, src/bus/sh7727.c,
src/bus/prototype.c, src/bus/sa1110.c, src/bus/ppc440gx_ebc8.c,
src/bus/tx4925.c, src/bus/sh7750r.c, src/bus/pxa2x0.c,
src/bus/bf533_stamp.c, src/bus/bf533_ezkit.c, src/bus/bf537_stamp.c,
src/bus/ixp425.c, src/bus/avr32.c, src/bus/h7202.c,
src/bus/zefant-xs3.c, src/bus/mpc824x.c, src/bus/bcm1250.c,
src/bus/sharc21065l.c, src/bus/au1500.c, src/bus/lh7a400.c,
src/bus/sh7751r.c, src/bus/generic_bus.c, src/bus/mpc5200.c,
src/bus/jopcyc.c, src/bus/bf561_ezkit.c, src/bus/slsup3.c,
src/bus/s3c4510x.c, src/bus/ejtag.c, src/bus/generic_bus.h:
[ 1984813 ] Bus driver cleanup, separate (*init) and (*prepare)
functions (Hartley Sweeten)
2008-06-24 Jie Zhang <jie.zhang@analog.com>
From Michael Hennerich <michael.hennerich@analog.com>

@ -1243,11 +1243,18 @@ IMPORTANT: Address parameters to the functions listed above specify always
byte locations, independent of the actual data width. The bus driver has to
adjust the address on its own if required.
===== Initialization =====
===== Creation =====
Upon calling of its bus_new() function, the driver allocates a "bus_t"
structure and performs all required internal initializations.
===== Initialization =====
After creation of the new "bus_t" structure, the bus_init() function will
be called to give the driver the possibility to initialize it's internal
states or BSR bits as required. Such functionality has been split from
bus_new() since some drivers require to re-initialize during runtime.
===== Cleaning up =====
The driver is supposed to free all allocated memory (including its "bus_t"

@ -68,6 +68,7 @@ struct bus {
chain_t *chain;
part_t *part;
void *params;
int initialized;
const bus_driver_t *driver;
};
@ -75,6 +76,7 @@ extern bus_t *bus;
#define CHAIN bus->chain
#define PART bus->part
#define INITIALIZED bus->initialized
#define bus_printinfo(bus) bus->driver->printinfo(bus)
#define bus_prepare(bus) bus->driver->prepare(bus)

@ -305,6 +305,6 @@ const bus_driver_t au1500_bus = {
au1500_bus_read_end,
generic_bus_read,
au1500_bus_write,
NULL
generic_bus_no_init
};

@ -577,6 +577,8 @@ avr32_bus_printinfo (bus_t * bus)
static void
avr32_bus_prepare (bus_t * bus)
{
if (!INITIALIZED)
bus_init( bus );
}
/**
@ -774,5 +776,5 @@ const bus_driver_t avr32_bus_driver = {
avr32_bus_read_end,
generic_bus_read,
avr32_bus_write,
NULL
generic_bus_no_init
};

@ -500,6 +500,6 @@ const bus_driver_t bcm1250_bus = {
bcm1250_bus_read,
#endif
bcm1250_bus_write,
NULL
generic_bus_no_init
};

@ -332,5 +332,5 @@ const bus_driver_t bf533_ezkit_bus = {
bf533_ezkit_bus_read_end,
generic_bus_read,
bf533_ezkit_bus_write,
NULL
generic_bus_no_init
};

@ -333,5 +333,5 @@ const bus_driver_t bf533_stamp_bus = {
bf533_stamp_bus_read_end,
generic_bus_read,
bf533_stamp_bus_write,
NULL
generic_bus_no_init
};

@ -347,7 +347,7 @@ const bus_driver_t bf537_stamp_bus = {
bf537_stamp_bus_read_end,
generic_bus_read,
bf537_stamp_bus_write,
NULL
generic_bus_no_init
};
#endif /* #ifdef ENABLE_BUS_BF537_STAMP */
@ -396,7 +396,7 @@ const bus_driver_t bf537_ezkit_bus = {
bf537_stamp_bus_read_end,
generic_bus_read,
bf537_stamp_bus_write,
NULL
generic_bus_no_init
};
#endif /* #ifdef ENABLE_BUS_BF537_EZKIT */
@ -445,7 +445,7 @@ const bus_driver_t bf527_ezkit_bus = {
bf537_stamp_bus_read_end,
generic_bus_read,
bf537_stamp_bus_write,
NULL
generic_bus_no_init
};
#endif /* #ifdef ENABLE_BUS_BF527_EZKIT */

@ -321,5 +321,5 @@ const bus_driver_t bf548_ezkit_bus = {
bf548_ezkit_bus_read_end,
generic_bus_read,
bf548_ezkit_bus_write,
NULL
generic_bus_no_init
};

@ -344,5 +344,5 @@ const bus_driver_t bf561_ezkit_bus = {
bf561_ezkit_bus_read_end,
generic_bus_read,
bf561_ezkit_bus_write,
NULL
generic_bus_no_init
};

@ -42,7 +42,6 @@
#include "generic_bus.h"
typedef struct {
int initialized;
uint32_t impcode; /* EJTAG Implementation Register */
uint16_t adr_hi; /* cached high bits of $3 */
} bus_params_t;
@ -90,7 +89,6 @@ ejtag_bus_new( chain_t *chain, char *cmd_params[] )
CHAIN = chain;
PART = chain->parts->parts[chain->active_part];
BP->initialized = 0;
return bus;
}
@ -156,14 +154,14 @@ ejtag_run_pracc( bus_t *bus, const uint32_t *code, unsigned int len )
printf( _("%s(%d) Reset occurred, ctrl=%s\n"),
__FILE__, __LINE__,
register_get_string( ejctrl->out ) );
BP->initialized = 0;
INITIALIZED = 0;
break;
}
if (! ejctrl->out->data[PrAcc]) {
printf( _("%s(%d) No processor access, ctrl=%s\n"),
__FILE__, __LINE__,
register_get_string( ejctrl->out ) );
BP->initialized = 0;
INITIALIZED = 0;
break;
}
@ -314,7 +312,7 @@ ejtag_bus_init( bus_t *bus )
ejtag_run_pracc( bus, code, 4 );
BP->adr_hi = 0;
BP->initialized = 1;
INITIALIZED = 1;
}
/**
@ -324,10 +322,8 @@ ejtag_bus_init( bus_t *bus )
static void
ejtag_bus_prepare( bus_t *bus )
{
if (BP->initialized)
return;
ejtag_bus_init( bus );
if (!INITIALIZED)
bus_init( bus );
}
/**
@ -501,5 +497,5 @@ const bus_driver_t ejtag_bus = {
ejtag_bus_read_end,
generic_bus_read,
ejtag_bus_write,
NULL
ejtag_bus_init
};

@ -480,6 +480,9 @@ fjmem_bus_printinfo( bus_t *bus )
static void
fjmem_bus_prepare( bus_t *bus )
{
if (!INITIALIZED)
bus_init( bus );
/* ensure FJMEM_INST is active */
part_set_instruction( PART, FJMEM_INST_NAME );
chain_shift_instructions( CHAIN );
@ -719,7 +722,7 @@ const bus_driver_t fjmem_bus = {
fjmem_bus_read_end,
generic_bus_read,
fjmem_bus_write,
NULL
generic_bus_no_init
};

@ -53,6 +53,18 @@ generic_bus_free( bus_t *bus )
free( bus );
}
/**
* bus->driver->(*init)
*
*/
int
generic_bus_no_init( bus_t *bus )
{
INITIALIZED = 1;
return 0;
}
/**
* bus->driver->(*prepare)
*
@ -60,6 +72,9 @@ generic_bus_free( bus_t *bus )
void
generic_bus_prepare_extest( bus_t *bus )
{
if (!INITIALIZED)
bus_init( bus );
part_set_instruction( PART, "EXTEST" );
chain_shift_instructions( CHAIN );
}

@ -30,6 +30,7 @@
int generic_bus_attach_sig( part_t *part, signal_t **sig, char *id );
void generic_bus_free( bus_t *bus );
int generic_bus_no_init( bus_t *bus );
void generic_bus_prepare_extest( bus_t *bus );
uint32_t generic_bus_read( bus_t *bus, uint32_t adr );

@ -305,5 +305,5 @@ const bus_driver_t h7202_bus = {
h7202_bus_read_end,
generic_bus_read,
h7202_bus_write,
NULL
generic_bus_no_init
};

@ -299,5 +299,5 @@ const bus_driver_t ixp425_bus = {
ixp425_bus_read_end,
generic_bus_read,
ixp425_bus_write,
NULL
generic_bus_no_init
};

@ -423,11 +423,11 @@ setup_data( bus_t *bus, uint32_t d, component_t *comp )
}
/**
* bus->driver->(*prepare)
* bus->driver->(*init)
*
*/
static void
jopcyc_bus_prepare( bus_t *bus )
static int
jopcyc_bus_init( bus_t *bus )
{
part_t *p = PART;
chain_t *chain = CHAIN;
@ -474,8 +474,9 @@ jopcyc_bus_prepare( bus_t *bus )
chain_shift_data_registers( chain, 0 );
part_set_instruction( p, "EXTEST" );
chain_shift_instructions( chain );
INITIALIZED = 1;
return 0;
}
static int
@ -668,14 +669,14 @@ const bus_driver_t jopcyc_bus = {
jopcyc_bus_new,
generic_bus_free,
jopcyc_bus_printinfo,
jopcyc_bus_prepare,
generic_bus_prepare_extest,
jopcyc_bus_area,
jopcyc_bus_read_start,
jopcyc_bus_read_next,
jopcyc_bus_read_end,
generic_bus_read,
jopcyc_bus_write,
NULL
jopcyc_bus_init
};

@ -328,5 +328,5 @@ const bus_driver_t lh7a400_bus = {
lh7a400_bus_read_end,
generic_bus_read,
lh7a400_bus_write,
NULL
generic_bus_no_init
};

@ -309,5 +309,5 @@ const bus_driver_t mpc5200_bus = {
mpc5200_bus_read_end,
generic_bus_read,
mpc5200_bus_write,
NULL
generic_bus_no_init
};

@ -521,5 +521,5 @@ const bus_driver_t mpc824x_bus = {
mpc824x_bus_read_end,
generic_bus_read,
mpc824x_bus_write,
NULL
generic_bus_no_init
};

@ -275,5 +275,5 @@ const bus_driver_t ppc405ep_bus = {
ppc405ep_bus_read_end,
generic_bus_read,
ppc405ep_bus_write,
NULL
generic_bus_no_init
};

@ -277,5 +277,5 @@ const bus_driver_t ppc440gx_ebc8_bus = {
ppc440gx_ebc8_bus_read_end,
generic_bus_read,
ppc440gx_ebc8_bus_write,
NULL
generic_bus_no_init
};

@ -446,6 +446,6 @@ const bus_driver_t prototype_bus = {
prototype_bus_read_end,
generic_bus_read,
prototype_bus_write,
NULL
generic_bus_no_init
};

@ -247,8 +247,6 @@ pxa2x0_bus_new( chain_t *chain, char *cmd_params[] )
return NULL;
}
INITED = 0;
return bus;
}
@ -288,8 +286,6 @@ pxa27x_bus_new( chain_t *chain, char *cmd_params[] )
return NULL;
}
INITED = 0;
return bus;
}
@ -333,9 +329,6 @@ pxa2xx_bus_init( bus_t *bus )
chain_t *chain = CHAIN;
part_t *p = PART;
if (INITED == 1)
return 0;
part_set_instruction( p, "SAMPLE/PRELOAD" );
chain_shift_instructions( chain );
chain_shift_data_registers( chain, 1 );
@ -358,23 +351,11 @@ pxa2xx_bus_init( bus_t *bus )
part_set_instruction( p, "BYPASS" );
chain_shift_instructions( chain );
INITED = 1;
INITIALIZED = 1;
return 0;
}
/**
* bus->driver->(*prepare)
*
*/
static void
pxa2xx_bus_prepare( bus_t *bus )
{
(void)pxa2xx_bus_init( bus );
generic_bus_prepare_extest( bus );
}
/**
* bus->driver->(*area)
*
@ -384,7 +365,6 @@ pxa2xx_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area )
{
uint32_t tmp_addr;
int ncs_index;
(void)pxa2xx_bus_init( bus );
/* Static Chip Select 0 (64 MB) */
if (adr < UINT32_C(0x04000000)) {
@ -475,7 +455,6 @@ pxa27x_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area )
{
uint32_t tmp_addr;
int ncs_index;
(void)pxa2xx_bus_init( bus );
/* Static Chip Select 0 (64 MB) */
if (adr < UINT32_C(0x04000000)) {
@ -793,14 +772,14 @@ const bus_driver_t pxa2x0_bus = {
pxa2x0_bus_new,
generic_bus_free,
pxa2x0_bus_printinfo,
pxa2xx_bus_prepare,
generic_bus_prepare_extest,
pxa2xx_bus_area,
pxa2xx_bus_read_start,
pxa2xx_bus_read_next,
pxa2xx_bus_read_end,
generic_bus_read,
pxa2xx_bus_write,
NULL /* patch 909598 call pxax0_bus_init, but the patch fails and doesnt look compatible */
pxa2xx_bus_init
};
const bus_driver_t pxa27x_bus = {
@ -809,7 +788,7 @@ const bus_driver_t pxa27x_bus = {
pxa27x_bus_new,
generic_bus_free,
pxa27x_bus_printinfo,
pxa2xx_bus_prepare,
generic_bus_prepare_extest,
pxa27x_bus_area,
pxa2xx_bus_read_start,
pxa2xx_bus_read_next,

@ -182,11 +182,11 @@ s3c4510_bus_printinfo( bus_t *bus )
}
/**
* bus->driver->(*prepare)
* bus->driver->(*init)
*
*/
static void
s3c4510_bus_prepare( bus_t *bus )
static int
s3c4510_bus_init( bus_t *bus )
{
part_t *p = PART;
chain_t *chain = CHAIN;
@ -195,8 +195,9 @@ s3c4510_bus_prepare( bus_t *bus )
chain_shift_instructions( chain );
chain_shift_data_registers( chain, 0 );
part_set_instruction( p, "EXTEST" );
chain_shift_instructions( chain );
INITIALIZED = 1;
return 0;
}
/**
@ -405,14 +406,14 @@ const bus_driver_t s3c4510_bus = {
s3c4510_bus_new,
generic_bus_free,
s3c4510_bus_printinfo,
s3c4510_bus_prepare,
generic_bus_prepare_extest,
s3c4510_bus_area,
s3c4510_bus_read_start,
s3c4510_bus_read_next,
s3c4510_bus_read_end,
generic_bus_read,
s3c4510_bus_write,
NULL
s3c4510_bus_init
};

@ -313,5 +313,5 @@ const bus_driver_t sa1110_bus = {
sa1110_bus_read_end,
generic_bus_read,
sa1110_bus_write,
NULL
generic_bus_no_init
};

@ -354,5 +354,5 @@ const bus_driver_t sh7727_bus = {
sh7727_bus_read_end,
generic_bus_read,
sh7727_bus_write,
NULL
generic_bus_no_init
};

@ -336,5 +336,5 @@ const bus_driver_t sh7750r_bus = {
sh7750r_bus_read_end,
generic_bus_read,
sh7750r_bus_write,
NULL
generic_bus_no_init
};

@ -324,5 +324,5 @@ const bus_driver_t sh7751r_bus = {
sh7751r_bus_read_end,
generic_bus_read,
sh7751r_bus_write,
NULL
generic_bus_no_init
};

@ -317,5 +317,5 @@ const bus_driver_t sharc_21065L_bus = {
sharc_21065L_bus_read_end,
generic_bus_read,
sharc_21065L_bus_write,
NULL
generic_bus_no_init
};

@ -431,5 +431,5 @@ const bus_driver_t slsup3_bus = {
slsup3_bus_read_end,
generic_bus_read,
slsup3_bus_write,
NULL
generic_bus_no_init
};

@ -319,5 +319,5 @@ const bus_driver_t tx4925_bus = {
tx4925_bus_read_end,
generic_bus_read,
tx4925_bus_write,
NULL
generic_bus_no_init
};

@ -545,11 +545,11 @@ eeprom_disable_device( chain_t *chain, part_t *p, component_t *comp )
}
/**
* bus->driver->(*prepare)
* bus->driver->(*init)
*
*/
static void
zefant_xs3_bus_prepare( bus_t *bus )
static int
zefant_xs3_bus_init( bus_t *bus )
{
part_t *p = PART;
chain_t *chain = CHAIN;
@ -605,8 +605,9 @@ zefant_xs3_bus_prepare( bus_t *bus )
chain_shift_data_registers( chain, 0 );
part_set_instruction( p, "EXTEST" );
chain_shift_instructions( chain );
INITIALIZED = 1;
return 0;
}
static int
@ -945,14 +946,14 @@ const bus_driver_t zefant_xs3_bus = {
zefant_xs3_bus_new,
generic_bus_free,
zefant_xs3_bus_printinfo,
zefant_xs3_bus_prepare,
generic_bus_prepare_extest,
zefant_xs3_bus_area,
zefant_xs3_bus_read_start,
zefant_xs3_bus_read_next,
zefant_xs3_bus_read_end,
generic_bus_read,
zefant_xs3_bus_write,
NULL
zefant_xs3_bus_init
};

@ -56,10 +56,12 @@ cmd_initbus_run( chain_t *chain, char *params[] )
if (strcasecmp( bus_drivers[i]->name, params[1] ) == 0) {
bus_t *bus = bus_drivers[i]->new_bus( chain, params );
if (bus == NULL) {
printf( _("bus initialization failed!\n") );
printf( _("bus alloc/attach failed!\n") );
return 1;
}
buses_add( bus );
if (bus_init( bus ))
printf( _("bus initialization failed!\n") );
return 1;
}
}

Loading…
Cancel
Save