X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fjtag%2Fzy1000%2Fzy1000.c;h=4626b7815185e3749cba85122c7223abd2ad36bb;hb=0e2c2fe1d1eec5482078147d551215a58604cc3a;hp=ad148f1d6d7c6c6ff41bf713d7e0f7b3c8504aef;hpb=3245a0cd5fdfcf27cc08a173e5c29abfd66882ee;p=openocd.git diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index ad148f1d6d..4626b78151 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -33,12 +33,9 @@ #define ZYLIN_TIME __TIME__ #define ZYLIN_OPENOCD "$Revision$" #define ZYLIN_OPENOCD_VERSION "Zylin JTAG ZY1000 " ZYLIN_VERSION " " ZYLIN_DATE " " ZYLIN_TIME -const char *zylin_config_dir="/config/settings"; /* low level command set */ -int zy1000_read(void); -static void zy1000_write(int tck, int tms, int tdi); void zy1000_reset(int trst, int srst); @@ -127,34 +124,22 @@ jtag_interface_t zy1000_interface = .srst_asserted = zy1000_srst_asserted, }; -static void zy1000_write(int tck, int tms, int tdi) -{ - -} - -int zy1000_read(void) -{ - return -1; -} - -extern bool readSRST(void); - void zy1000_reset(int trst, int srst) { LOG_DEBUG("zy1000 trst=%d, srst=%d", trst, srst); - if(!srst) + if (!srst) { ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000001); } else { - /* Danger!!! if clk!=0 when in + /* Danger!!! if clk != 0 when in * idle in TAP_IDLE, reset halt on str912 will fail. */ ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000001); } - if(!trst) + if (!trst) { ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000002); } @@ -164,7 +149,7 @@ void zy1000_reset(int trst, int srst) ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000002); } - if (trst||(srst&&(jtag_reset_config & RESET_SRST_PULLS_TRST))) + if (trst||(srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST))) { waitIdle(); /* we're now in the RESET state until trst is deasserted */ @@ -203,7 +188,7 @@ void zy1000_reset(int trst, int srst) int zy1000_speed(int speed) { - if(speed == 0) + if (speed == 0) { /*0 means RCLK*/ speed = 0; @@ -212,7 +197,7 @@ int zy1000_speed(int speed) } else { - if(speed > 8190 || speed < 2) + if (speed > 8190 || speed < 2) { LOG_USER("valid ZY1000 jtag_speed=[8190,2]. Divisor is 64MHz / even values between 8190-2, i.e. min 7814Hz, max 32MHz"); return ERROR_INVALID_ARGUMENTS; @@ -324,7 +309,7 @@ zylinjtag_Jim_Command_powerstatus(Jim_Interp *interp, cyg_uint32 status; ZY1000_PEEK(ZY1000_JTAG_BASE+0x10, status); - Jim_SetResult(interp, Jim_NewIntObj(interp, (status&0x80)!=0)); + Jim_SetResult(interp, Jim_NewIntObj(interp, (status&0x80) != 0)); return JIM_OK; } @@ -356,7 +341,7 @@ int zy1000_init(void) /* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */ zy1000_reset(0, 0); - zy1000_speed(jtag_speed); + zy1000_speed(jtag_get_speed()); return ERROR_OK; } @@ -378,7 +363,7 @@ int interface_jtag_execute_queue(void) /* clear JTAG error register */ ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x400); - if ((empty&0x400)!=0) + if ((empty&0x400) != 0) { LOG_WARNING("RCLK timeout"); /* the error is informative only as we don't want to break the firmware if there @@ -425,9 +410,9 @@ static void shiftValueInnerFlip(const tap_state_t state, const tap_state_t endSt } #endif -extern int jtag_check_value(u8 *captured, void *priv); +extern int jtag_check_value(uint8_t *captured, void *priv); -static __inline void scanFields(int num_fields, scan_field_t *fields, tap_state_t shiftState, tap_state_t end_state) +static __inline void scanFields(int num_fields, const scan_field_t *fields, tap_state_t shiftState, tap_state_t end_state) { int i; int j; @@ -437,14 +422,12 @@ static __inline void scanFields(int num_fields, scan_field_t *fields, tap_state_ { cyg_uint32 value; - static u8 *in_buff=NULL; /* pointer to buffer for scanned data */ - static int in_buff_size=0; - u8 *inBuffer=NULL; + uint8_t *inBuffer=NULL; // figure out where to store the input data int num_bits=fields[i].num_bits; - if (fields[i].in_value!=NULL) + if (fields[i].in_value != NULL) { inBuffer=fields[i].in_value; } @@ -470,31 +453,31 @@ static __inline void scanFields(int num_fields, scan_field_t *fields, tap_state_ // we have (num_bits+7)/8 bytes of bits to toggle out. // bits are pushed out LSB to MSB value=0; - if (fields[i].out_value!=NULL) + if (fields[i].out_value != NULL) { - for (l=0; l>= 32-k; - for (l=0; l>l)&0xff; + inBuffer[(j+l)/8]=(value >> l)&0xff; } } - j+=k; + j += k; } } } @@ -511,7 +494,7 @@ int interface_jtag_add_ir_scan(int num_fields, const scan_field_t *fields, tap_s int j; int scan_size = 0; jtag_tap_t *tap, *nextTap; - for(tap = jtag_tap_next_enabled(NULL); tap!= NULL; tap=nextTap) + for (tap = jtag_tap_next_enabled(NULL); tap!= NULL; tap=nextTap) { nextTap=jtag_tap_next_enabled(tap); tap_state_t end_state; @@ -546,7 +529,7 @@ int interface_jtag_add_ir_scan(int num_fields, const scan_field_t *fields, tap_s if (!found) { /* if a device isn't listed, set it to BYPASS */ - u8 ones[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; + uint8_t ones[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; scan_field_t tmp; memset(&tmp, 0, sizeof(tmp)); @@ -580,7 +563,7 @@ int interface_jtag_add_dr_scan(int num_fields, const scan_field_t *fields, tap_s int j; jtag_tap_t *tap, *nextTap; - for(tap = jtag_tap_next_enabled(NULL); tap!= NULL; tap=nextTap) + for (tap = jtag_tap_next_enabled(NULL); tap!= NULL; tap=nextTap) { nextTap=jtag_tap_next_enabled(tap); int found=0; @@ -651,7 +634,7 @@ static int zy1000_jtag_add_clocks(int num_cycles, tap_state_t state, tap_state_t /* execute num_cycles, 32 at the time. */ int i; - for (i=0; i 1) - len = 1; - result = strncmp((char *) data, "1", len) == 0; - free(data); - } - free(name); - return result; -} -