more global to local variable substitution

[ 1929235 ] Use less global and static variables


git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1150 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Arnim Läuger 17 years ago
parent ca56030f9a
commit 7f26d5814d

@ -1,6 +1,8 @@
2008-04-03 Arnim Laeuger <arniml@users.sourceforge.net>
[ 1929235 ] Use less global and static variables:
* src/bus/jopcyc.c, src/bus/zefant-xs3.c: made global variable
last_address local
* src/svf/svf.c, src/svf/svf.h: support reentrant parser and scanner
* src/svf/svf_bison.y: provisions for reentrant parser
* src/svf/svf_flex.l: made scanner reentrant

@ -100,6 +100,7 @@ typedef struct {
typedef struct {
chain_t *chain;
part_t *part;
uint32_t last_addr; /* holds last address of read or write access */
component_t rama;
component_t ramb;
component_t flash;
@ -109,17 +110,18 @@ typedef struct {
signal_t *ser_ncts;
} bus_params_t;
#define CHAIN ((bus_params_t *) bus->params)->chain
#define PART ((bus_params_t *) bus->params)->part
#define A comp->a
#define D comp->d
#define nCS comp->ncs
#define nOE comp->noe
#define nWE comp->nwe
#define nLB comp->nlb
#define nUB comp->nub
#define nCS2 comp->ncs2
#define nRDY comp->nrdy
#define CHAIN ((bus_params_t *) bus->params)->chain
#define PART ((bus_params_t *) bus->params)->part
#define LAST_ADDR ((bus_params_t *) bus->params)->last_addr
#define A comp->a
#define D comp->d
#define nCS comp->ncs
#define nOE comp->noe
#define nWE comp->nwe
#define nLB comp->nlb
#define nUB comp->nub
#define nCS2 comp->ncs2
#define nRDY comp->nrdy
#define COMP_RAMA &(((bus_params_t *) bus->params)->rama)
#define COMP_RAMB &(((bus_params_t *) bus->params)->ramb)
@ -130,8 +132,6 @@ typedef struct {
#define SER_TXD ((bus_params_t *) bus->params)->ser_txd
#define SER_NCTS ((bus_params_t *) bus->params)->ser_ncts
/* holds last address of read or write access */
static uint32_t last_address = 0;
static void
setup_address( bus_t *bus, uint32_t a, component_t *comp )
@ -140,7 +140,7 @@ setup_address( bus_t *bus, uint32_t a, component_t *comp )
part_t *p = PART;
int addr_width;
last_address = a;
LAST_ADDR = a;
switch (comp->ctype) {
case RAM:
@ -295,7 +295,7 @@ jopcyc_bus_read_start( bus_t *bus, uint32_t adr )
comp_bus_area( bus, adr, &area, &comp );
if (!comp) {
printf( _("Address out of range\n") );
last_address = adr;
LAST_ADDR = adr;
return;
}
@ -330,7 +330,7 @@ jopcyc_bus_read_next( bus_t *bus, uint32_t adr )
comp_bus_area( bus, adr, &area, &comp );
if (!comp) {
printf( _("Address out of range\n") );
last_address = adr;
LAST_ADDR = adr;
return 0;
}
@ -358,7 +358,7 @@ jopcyc_bus_read_end( bus_t *bus )
component_t *comp;
/* use last address of access to determine component */
comp_bus_area( bus, last_address, &area, &comp );
comp_bus_area( bus, LAST_ADDR, &area, &comp );
if (!comp) {
printf( _("Address out of range\n") );
return 0;
@ -716,3 +716,12 @@ const bus_driver_t jopcyc_bus = {
jopcyc_bus_write,
NULL
};
/*
Local Variables:
mode:C
tab-width:2
indent-tabs-mode:t
End:
*/

@ -119,6 +119,7 @@ typedef struct {
typedef struct {
chain_t *chain;
part_t *part;
uint32_t last_addr; /* holds last address of read or write access */
component_t flash;
component_t ram0;
component_t ram1;
@ -126,21 +127,22 @@ typedef struct {
component_t eeprom_status;
} bus_params_t;
#define CHAIN ((bus_params_t *) bus->params)->chain
#define PART ((bus_params_t *) bus->params)->part
#define A comp->a
#define D comp->d
#define nCS comp->ncs
#define nOE comp->noe
#define nWE comp->nwe
#define nLB comp->nlb
#define nUB comp->nub
#define nBYTE comp->nbyte
#define STS comp->sts
#define nRP comp->nrp
#define SI comp->si
#define SO comp->so
#define SCK comp->sck
#define CHAIN ((bus_params_t *) bus->params)->chain
#define PART ((bus_params_t *) bus->params)->part
#define LAST_ADDR ((bus_params_t *) bus->params)->last_addr
#define A comp->a
#define D comp->d
#define nCS comp->ncs
#define nOE comp->noe
#define nWE comp->nwe
#define nLB comp->nlb
#define nUB comp->nub
#define nBYTE comp->nbyte
#define STS comp->sts
#define nRP comp->nrp
#define SI comp->si
#define SO comp->so
#define SCK comp->sck
#define COMP_FLASH &(((bus_params_t *) bus->params)->flash)
#define COMP_RAM0 &(((bus_params_t *) bus->params)->ram0)
@ -148,9 +150,6 @@ typedef struct {
#define COMP_EEPROM &(((bus_params_t *) bus->params)->eeprom)
#define COMP_EEPROM_STATUS &(((bus_params_t *) bus->params)->eeprom_status)
/* holds last address of read or write access */
static uint32_t last_address = 0;
static void
setup_address( bus_t *bus, uint32_t a, component_t *comp )
{
@ -158,7 +157,7 @@ setup_address( bus_t *bus, uint32_t a, component_t *comp )
part_t *p = PART;
int addr_width;
last_address = a;
LAST_ADDR = a;
switch (comp->ctype) {
case FLASH:
@ -373,7 +372,7 @@ zefant_xs3_bus_read_start( bus_t *bus, uint32_t adr )
comp_bus_area( bus, adr, &area, &comp );
if (!comp) {
printf( _("Address out of range\n") );
last_address = adr;
LAST_ADDR = adr;
return;
}
@ -413,7 +412,7 @@ zefant_xs3_bus_read_start( bus_t *bus, uint32_t adr )
eeprom_shift_byte( chain, p, comp, adr & 0xff);
}
last_address = adr;
LAST_ADDR = adr;
break;
default:
@ -440,7 +439,7 @@ zefant_xs3_bus_read_next( bus_t *bus, uint32_t adr )
comp_bus_area( bus, adr, &area, &comp );
if (!comp) {
printf( _("Address out of range\n") );
last_address = adr;
LAST_ADDR = adr;
return 0;
}
@ -485,7 +484,7 @@ zefant_xs3_bus_read_end( bus_t *bus )
component_t *comp;
/* use last address of access to determine component */
comp_bus_area( bus, last_address, &area, &comp );
comp_bus_area( bus, LAST_ADDR, &area, &comp );
if (!comp) {
printf( _("Address out of range\n") );
return 0;

Loading…
Cancel
Save