diff --git a/jtag/ChangeLog b/jtag/ChangeLog index e84df27f..295d2560 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,9 @@ +2008-01-25 Kolja Waschk + + * include/jim.h, src/jim/tap.c, intel_28f800b3.c, Makefile.am, + some_cpu.c: Code skeleton and alloc/free calls for actual parts + connected to JIM's some_cpu + 2008-01-24 Kolja Waschk * tap/cable/ft2232.c, tap/parport/ftdi.c, tap/cable.c: added support diff --git a/jtag/include/jim.h b/jtag/include/jim.h index 8257c823..d8941769 100644 --- a/jtag/include/jim.h +++ b/jtag/include/jim.h @@ -71,6 +71,7 @@ typedef struct jim_device void (*tck_rise)(struct jim_device *dev, int tms, int tdi); void (*tck_fall)(struct jim_device *dev); void (*dev_free)(struct jim_device *dev); + void *state; int num_sregs; int current_dr; shift_reg_t *sreg; @@ -86,6 +87,24 @@ typedef struct jim_state } jim_state_t; +typedef struct jim_bus_device +{ + int width; /* bits */ + uint32_t size; /* bytes */ + void *state; /* device-dependent */ + void (*init)(struct jim_bus_device *x); + void (*access)(struct jim_bus_device *x, + uint32_t address, uint32_t data, uint32_t control); + void (*free)(struct jim_bus_device *x); +} +jim_bus_device_t; + +typedef struct +{ + uint32_t offset; + jim_bus_device_t *part; +} +jim_attached_part_t; void jim_set_trst(jim_state_t *s, int trst); int jim_get_trst(jim_state_t *s); diff --git a/jtag/src/jim/Makefile.am b/jtag/src/jim/Makefile.am index 60bbeba6..f38124a7 100644 --- a/jtag/src/jim/Makefile.am +++ b/jtag/src/jim/Makefile.am @@ -27,4 +27,5 @@ noinst_LIBRARIES = libjim.a libjim_a_SOURCES = \ tap.c \ - some_cpu.c + some_cpu.c \ + intel_28f800b3.c diff --git a/jtag/src/jim/intel_28f800b3.c b/jtag/src/jim/intel_28f800b3.c new file mode 100644 index 00000000..3301e2b4 --- /dev/null +++ b/jtag/src/jim/intel_28f800b3.c @@ -0,0 +1,27 @@ +#include +#include +#include + +void intel_28f800b3_init(jim_bus_device_t *d) +{ +} + +void intel_28f800b3_free(jim_bus_device_t *d) +{ +} + +void intel_28f800b3_access(jim_bus_device_t *d, + uint32_t address, uint32_t data, uint32_t control) +{ +} + +jim_bus_device_t intel_28f800b3 = +{ + 16, /* width [bits] */ + 0x800, /* size [bytes] */ + NULL, /* state */ + intel_28f800b3_init, /* init() */ + intel_28f800b3_access, /* access() */ + intel_28f800b3_free /* free() */ +}; + diff --git a/jtag/src/jim/some_cpu.c b/jtag/src/jim/some_cpu.c index 038b9ea3..513b10f5 100644 --- a/jtag/src/jim/some_cpu.c +++ b/jtag/src/jim/some_cpu.c @@ -23,8 +23,18 @@ */ #include +#include +#include #include +extern jim_bus_device_t intel_28f800b3; + +jim_attached_part_t some_cpu_attached[] = +{ + { 0x00000000, &intel_28f800b3 }, + { 0xFFFFFFFF, NULL } +}; + #define BSR_LEN 202 void some_cpu_report_idcode(jim_device_t *dev) @@ -34,10 +44,28 @@ void some_cpu_report_idcode(jim_device_t *dev) dev->current_dr = 1; /* IDR */ } -void some_cpu_tck_rise(jim_device_t *dev, int tms, int tdi) +void some_cpu_extest(char *st, jim_device_t *dev) { int i; + printf("EXTEST/%s with A=%08X, D=%08X%s%s%s\n", st, + dev->sreg[2].reg[0], dev->sreg[2].reg[1], + (dev->sreg[2].reg[2] & 1) ? ", OE":"", + (dev->sreg[2].reg[2] & 2) ? ", WE":"", + (dev->sreg[2].reg[2] & 4) ? ", CS":""); + + for(i=0; some_cpu_attached[i].part; i++) + { + jim_bus_device_t *b = ((jim_attached_part_t*)(dev->state))[i].part; + + b->access(b, dev->sreg[2].reg[0], + dev->sreg[2].reg[1], + dev->sreg[2].reg[2]); + } +} + +void some_cpu_tck_rise(jim_device_t *dev, int tms, int tdi) +{ // jim_print_tap_state(dev); switch(dev->tap_state) @@ -49,12 +77,7 @@ void some_cpu_tck_rise(jim_device_t *dev, int tms, int tdi) case UPDATE_DR: if(dev->current_dr == 2) { - printf("UPDATE_DR(BSR): A=%08X, D=%08X%s%s%s\n", - dev->sreg[2].reg[0], - dev->sreg[2].reg[1], - (dev->sreg[2].reg[2] & 1) ? ", OE":"", - (dev->sreg[2].reg[2] & 2) ? ", WE":"", - (dev->sreg[2].reg[2] & 4) ? ", CS":""); + if(dev->sreg[0].reg[0] == 0) some_cpu_extest("UPDATE_DR", dev); }; break; @@ -64,6 +87,7 @@ void some_cpu_tck_rise(jim_device_t *dev, int tms, int tdi) case 0x0: /* EXTEST */ printf("EXTEST\n"); dev->current_dr = 2; + some_cpu_extest("UPDATE_IR", dev); break; case 0x1: /* IDCODE */ printf("IDCODE\n"); @@ -86,6 +110,21 @@ void some_cpu_tck_rise(jim_device_t *dev, int tms, int tdi) } } +void some_cpu_free(jim_device_t *dev) +{ + int i; + + if(!dev) return; + if(!dev->state) return; + + for(i=0;some_cpu_attached[i].part;i++) + { + jim_bus_device_t *b = ((jim_attached_part_t*)(dev->state))[i].part; + if(b->free != NULL) b->free(b); + } + free(dev->state); +} + jim_device_t *some_cpu(void) { jim_device_t *dev; @@ -95,7 +134,24 @@ jim_device_t *some_cpu(void) if(dev) { - dev->tck_rise = some_cpu_tck_rise; + dev->state = malloc(sizeof(some_cpu_attached)); + if(!dev->state) + { + free(dev); + dev = NULL; + } + else + { + int i; + dev->tck_rise = some_cpu_tck_rise; + dev->dev_free = some_cpu_free; + memcpy(dev->state, some_cpu_attached, sizeof(some_cpu_attached)); + for(i=0;some_cpu_attached[i].part;i++) + { + jim_bus_device_t *b = ((jim_attached_part_t*)(dev->state))[i].part; + b->init(b); + } + } } return dev; diff --git a/jtag/src/jim/tap.c b/jtag/src/jim/tap.c index d8271fda..97e0135f 100644 --- a/jtag/src/jim/tap.c +++ b/jtag/src/jim/tap.c @@ -248,6 +248,7 @@ jim_state_t *jim_init(void) s->trst = 0; s->last_device_in_chain = some_cpu(); + if(s->last_device_in_chain != NULL) { s->last_device_in_chain->prev = NULL;