You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

814 lines
17 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2007-2008 by Øyvind Harboe *
  3. * *
  4. * This program is free software; you can redistribute it and/or modify *
  5. * it under the terms of the GNU General Public License as published by *
  6. * the Free Software Foundation; either version 2 of the License, or *
  7. * (at your option) any later version. *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program; if not, write to the *
  16. * Free Software Foundation, Inc., *
  17. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  18. ***************************************************************************/
  19. #ifdef HAVE_CONFIG_H
  20. #include "config.h"
  21. #endif
  22. #include "embeddedice.h"
  23. #include "minidriver.h"
  24. #include "interface.h"
  25. #include <cyg/hal/hal_io.h> // low level i/o
  26. #include <cyg/hal/hal_diag.h>
  27. #define ZYLIN_VERSION "1.52"
  28. #define ZYLIN_DATE __DATE__
  29. #define ZYLIN_TIME __TIME__
  30. #define ZYLIN_OPENOCD "$Revision$"
  31. #define ZYLIN_OPENOCD_VERSION "Zylin JTAG ZY1000 " ZYLIN_VERSION " " ZYLIN_DATE " " ZYLIN_TIME
  32. /* low level command set
  33. */
  34. void zy1000_reset(int trst, int srst);
  35. int zy1000_speed(int speed);
  36. int zy1000_register_commands(struct command_context_s *cmd_ctx);
  37. int zy1000_init(void);
  38. int zy1000_quit(void);
  39. /* interface commands */
  40. int zy1000_handle_zy1000_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
  41. static int zy1000_khz(int khz, int *jtag_speed)
  42. {
  43. if (khz == 0)
  44. {
  45. *jtag_speed = 0;
  46. }
  47. else
  48. {
  49. *jtag_speed = 64000/khz;
  50. }
  51. return ERROR_OK;
  52. }
  53. static int zy1000_speed_div(int speed, int *khz)
  54. {
  55. if (speed == 0)
  56. {
  57. *khz = 0;
  58. }
  59. else
  60. {
  61. *khz = 64000/speed;
  62. }
  63. return ERROR_OK;
  64. }
  65. static bool readPowerDropout(void)
  66. {
  67. cyg_uint32 state;
  68. // sample and clear power dropout
  69. HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x80);
  70. HAL_READ_UINT32(ZY1000_JTAG_BASE + 0x10, state);
  71. bool powerDropout;
  72. powerDropout = (state & 0x80) != 0;
  73. return powerDropout;
  74. }
  75. static bool readSRST(void)
  76. {
  77. cyg_uint32 state;
  78. // sample and clear SRST sensing
  79. HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x00000040);
  80. HAL_READ_UINT32(ZY1000_JTAG_BASE + 0x10, state);
  81. bool srstAsserted;
  82. srstAsserted = (state & 0x40) != 0;
  83. return srstAsserted;
  84. }
  85. static int zy1000_srst_asserted(int *srst_asserted)
  86. {
  87. *srst_asserted = readSRST();
  88. return ERROR_OK;
  89. }
  90. static int zy1000_power_dropout(int *dropout)
  91. {
  92. *dropout = readPowerDropout();
  93. return ERROR_OK;
  94. }
  95. jtag_interface_t zy1000_interface =
  96. {
  97. .name = "ZY1000",
  98. .execute_queue = NULL,
  99. .speed = zy1000_speed,
  100. .register_commands = zy1000_register_commands,
  101. .init = zy1000_init,
  102. .quit = zy1000_quit,
  103. .khz = zy1000_khz,
  104. .speed_div = zy1000_speed_div,
  105. .power_dropout = zy1000_power_dropout,
  106. .srst_asserted = zy1000_srst_asserted,
  107. };
  108. void zy1000_reset(int trst, int srst)
  109. {
  110. LOG_DEBUG("zy1000 trst=%d, srst=%d", trst, srst);
  111. if (!srst)
  112. {
  113. ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x00000001);
  114. }
  115. else
  116. {
  117. /* Danger!!! if clk != 0 when in
  118. * idle in TAP_IDLE, reset halt on str912 will fail.
  119. */
  120. ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x00000001);
  121. }
  122. if (!trst)
  123. {
  124. ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x00000002);
  125. }
  126. else
  127. {
  128. /* assert reset */
  129. ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x00000002);
  130. }
  131. if (trst||(srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
  132. {
  133. waitIdle();
  134. /* we're now in the RESET state until trst is deasserted */
  135. ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, TAP_RESET);
  136. } else
  137. {
  138. /* We'll get RCLK failure when we assert TRST, so clear any false positives here */
  139. ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x400);
  140. }
  141. /* wait for srst to float back up */
  142. if (!srst)
  143. {
  144. int i;
  145. for (i = 0; i < 1000; i++)
  146. {
  147. // We don't want to sense our own reset, so we clear here.
  148. // There is of course a timing hole where we could loose
  149. // a "real" reset.
  150. if (!readSRST())
  151. break;
  152. /* wait 1ms */
  153. alive_sleep(1);
  154. }
  155. if (i == 1000)
  156. {
  157. LOG_USER("SRST didn't deassert after %dms", i);
  158. } else if (i > 1)
  159. {
  160. LOG_USER("SRST took %dms to deassert", i);
  161. }
  162. }
  163. }
  164. int zy1000_speed(int speed)
  165. {
  166. if (speed == 0)
  167. {
  168. /*0 means RCLK*/
  169. speed = 0;
  170. ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x100);
  171. LOG_DEBUG("jtag_speed using RCLK");
  172. }
  173. else
  174. {
  175. if (speed > 8190 || speed < 2)
  176. {
  177. LOG_USER("valid ZY1000 jtag_speed=[8190,2]. Divisor is 64MHz / even values between 8190-2, i.e. min 7814Hz, max 32MHz");
  178. return ERROR_INVALID_ARGUMENTS;
  179. }
  180. LOG_USER("jtag_speed %d => JTAG clk=%f", speed, 64.0/(float)speed);
  181. ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x100);
  182. ZY1000_POKE(ZY1000_JTAG_BASE + 0x1c, speed&~1);
  183. }
  184. return ERROR_OK;
  185. }
  186. static bool savePower;
  187. static void setPower(bool power)
  188. {
  189. savePower = power;
  190. if (power)
  191. {
  192. HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x14, 0x8);
  193. } else
  194. {
  195. HAL_WRITE_UINT32(ZY1000_JTAG_BASE + 0x10, 0x8);
  196. }
  197. }
  198. int handle_power_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
  199. {
  200. if (argc > 1)
  201. {
  202. return ERROR_INVALID_ARGUMENTS;
  203. }
  204. if (argc == 1)
  205. {
  206. if (strcmp(args[0], "on") == 0)
  207. {
  208. setPower(1);
  209. }
  210. else if (strcmp(args[0], "off") == 0)
  211. {
  212. setPower(0);
  213. } else
  214. {
  215. command_print(cmd_ctx, "arg is \"on\" or \"off\"");
  216. return ERROR_INVALID_ARGUMENTS;
  217. }
  218. }
  219. command_print(cmd_ctx, "Target power %s", savePower ? "on" : "off");
  220. return ERROR_OK;
  221. }
  222. /* Give TELNET a way to find out what version this is */
  223. static int jim_zy1000_version(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
  224. {
  225. if ((argc < 1) || (argc > 2))
  226. return JIM_ERR;
  227. char buff[128];
  228. const char *version_str = NULL;
  229. if (argc == 1)
  230. {
  231. version_str = ZYLIN_OPENOCD_VERSION;
  232. } else
  233. {
  234. const char *str = Jim_GetString(argv[1], NULL);
  235. if (strcmp("openocd", str) == 0)
  236. {
  237. int revision;
  238. revision = atol(ZYLIN_OPENOCD + strlen("XRevision: "));
  239. sprintf(buff, "%d", revision);
  240. version_str = buff;
  241. }
  242. else if (strcmp("zy1000", str) == 0)
  243. {
  244. version_str = ZYLIN_VERSION;
  245. }
  246. else if (strcmp("date", str) == 0)
  247. {
  248. version_str = ZYLIN_DATE;
  249. }
  250. else if (strcmp("pcb", str) == 0)
  251. {
  252. #ifdef CYGPKG_HAL_NIOS2
  253. version_str="c";
  254. #else
  255. version_str="b";
  256. #endif
  257. }
  258. else
  259. {
  260. return JIM_ERR;
  261. }
  262. }
  263. Jim_SetResult(interp, Jim_NewStringObj(interp, version_str, -1));
  264. return JIM_OK;
  265. }
  266. #ifdef CYGPKG_HAL_NIOS2
  267. static int jim_zy1000_writefirmware(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
  268. {
  269. if (argc != 2)
  270. return JIM_ERR;
  271. int length;
  272. int stat;
  273. const char *str = Jim_GetString(argv[1], &length);
  274. /* BUG!!!! skip header! */
  275. void *firmware_address=0x4000000;
  276. int firmware_length=0x100000;
  277. if (length>firmware_length)
  278. return JIM_ERR;
  279. void *err_addr;
  280. if ((stat = flash_erase((void *)firmware_address, firmware_length, (void **)&err_addr)) != 0)
  281. {
  282. return JIM_ERR;
  283. }
  284. if ((stat = flash_program(firmware_address, str, length, (void **)&err_addr)) != 0)
  285. return JIM_ERR;
  286. return JIM_OK;
  287. }
  288. #endif
  289. static int
  290. zylinjtag_Jim_Command_powerstatus(Jim_Interp *interp,
  291. int argc,
  292. Jim_Obj * const *argv)
  293. {
  294. if (argc != 1)
  295. {
  296. Jim_WrongNumArgs(interp, 1, argv, "powerstatus");
  297. return JIM_ERR;
  298. }
  299. cyg_uint32 status;
  300. ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, status);
  301. Jim_SetResult(interp, Jim_NewIntObj(interp, (status&0x80) != 0));
  302. return JIM_OK;
  303. }
  304. int zy1000_register_commands(struct command_context_s *cmd_ctx)
  305. {
  306. register_command(cmd_ctx, NULL, "power", handle_power_command, COMMAND_ANY,
  307. "power <on/off> - turn power switch to target on/off. No arguments - print status.");
  308. Jim_CreateCommand(interp, "zy1000_version", jim_zy1000_version, NULL, NULL);
  309. Jim_CreateCommand(interp, "powerstatus", zylinjtag_Jim_Command_powerstatus, NULL, NULL);
  310. #ifdef CYGPKG_HAL_NIOS2
  311. Jim_CreateCommand(interp, "updatezy1000firmware", jim_zy1000_writefirmware, NULL, NULL);
  312. #endif
  313. return ERROR_OK;
  314. }
  315. int zy1000_init(void)
  316. {
  317. LOG_USER("%s", ZYLIN_OPENOCD_VERSION);
  318. ZY1000_POKE(ZY1000_JTAG_BASE + 0x10, 0x30); // Turn on LED1 & LED2
  319. setPower(true); // on by default
  320. /* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */
  321. zy1000_reset(0, 0);
  322. zy1000_speed(jtag_get_speed());
  323. return ERROR_OK;
  324. }
  325. int zy1000_quit(void)
  326. {
  327. return ERROR_OK;
  328. }
  329. int interface_jtag_execute_queue(void)
  330. {
  331. cyg_uint32 empty;
  332. waitIdle();
  333. ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, empty);
  334. /* clear JTAG error register */
  335. ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x400);
  336. if ((empty&0x400) != 0)
  337. {
  338. LOG_WARNING("RCLK timeout");
  339. /* the error is informative only as we don't want to break the firmware if there
  340. * is a false positive.
  341. */
  342. // return ERROR_FAIL;
  343. }
  344. return ERROR_OK;
  345. }
  346. static cyg_uint32 getShiftValue(void)
  347. {
  348. cyg_uint32 value;
  349. waitIdle();
  350. ZY1000_PEEK(ZY1000_JTAG_BASE + 0xc, value);
  351. VERBOSE(LOG_INFO("getShiftValue %08x", value));
  352. return value;
  353. }
  354. #if 0
  355. static cyg_uint32 getShiftValueFlip(void)
  356. {
  357. cyg_uint32 value;
  358. waitIdle();
  359. ZY1000_PEEK(ZY1000_JTAG_BASE + 0x18, value);
  360. VERBOSE(LOG_INFO("getShiftValue %08x (flipped)", value));
  361. return value;
  362. }
  363. #endif
  364. #if 0
  365. static void shiftValueInnerFlip(const tap_state_t state, const tap_state_t endState, int repeat, cyg_uint32 value)
  366. {
  367. VERBOSE(LOG_INFO("shiftValueInner %s %s %d %08x (flipped)", tap_state_name(state), tap_state_name(endState), repeat, value));
  368. cyg_uint32 a,b;
  369. a = state;
  370. b = endState;
  371. ZY1000_POKE(ZY1000_JTAG_BASE + 0xc, value);
  372. ZY1000_POKE(ZY1000_JTAG_BASE + 0x8, (1 << 15) | (repeat << 8) | (a << 4) | b);
  373. VERBOSE(getShiftValueFlip());
  374. }
  375. #endif
  376. extern int jtag_check_value(uint8_t *captured, void *priv);
  377. static __inline void scanFields(int num_fields, const scan_field_t *fields, tap_state_t shiftState, tap_state_t end_state)
  378. {
  379. int i;
  380. int j;
  381. int k;
  382. for (i = 0; i < num_fields; i++)
  383. {
  384. cyg_uint32 value;
  385. uint8_t *inBuffer = NULL;
  386. // figure out where to store the input data
  387. int num_bits = fields[i].num_bits;
  388. if (fields[i].in_value != NULL)
  389. {
  390. inBuffer = fields[i].in_value;
  391. }
  392. // here we shuffle N bits out/in
  393. j = 0;
  394. while (j < num_bits)
  395. {
  396. tap_state_t pause_state;
  397. int l;
  398. k = num_bits-j;
  399. pause_state = (shiftState == TAP_DRSHIFT)?TAP_DRSHIFT:TAP_IRSHIFT;
  400. if (k > 32)
  401. {
  402. k = 32;
  403. /* we have more to shift out */
  404. } else if (i == num_fields-1)
  405. {
  406. /* this was the last to shift out this time */
  407. pause_state = end_state;
  408. }
  409. // we have (num_bits + 7)/8 bytes of bits to toggle out.
  410. // bits are pushed out LSB to MSB
  411. value = 0;
  412. if (fields[i].out_value != NULL)
  413. {
  414. for (l = 0; l < k; l += 8)
  415. {
  416. value|=fields[i].out_value[(j + l)/8]<<l;
  417. }
  418. }
  419. /* mask away unused bits for easier debugging */
  420. value&=~(((uint32_t)0xffffffff) << k);
  421. shiftValueInner(shiftState, pause_state, k, value);
  422. if (inBuffer != NULL)
  423. {
  424. // data in, LSB to MSB
  425. value = getShiftValue();
  426. // we're shifting in data to MSB, shift data to be aligned for returning the value
  427. value >>= 32-k;
  428. for (l = 0; l < k; l += 8)
  429. {
  430. inBuffer[(j + l)/8]=(value >> l)&0xff;
  431. }
  432. }
  433. j += k;
  434. }
  435. }
  436. }
  437. int interface_jtag_set_end_state(tap_state_t state)
  438. {
  439. return ERROR_OK;
  440. }
  441. int interface_jtag_add_ir_scan(int num_fields, const scan_field_t *fields, tap_state_t state)
  442. {
  443. int j;
  444. int scan_size = 0;
  445. jtag_tap_t *tap, *nextTap;
  446. for (tap = jtag_tap_next_enabled(NULL); tap!= NULL; tap = nextTap)
  447. {
  448. nextTap = jtag_tap_next_enabled(tap);
  449. tap_state_t end_state;
  450. if (nextTap == NULL)
  451. {
  452. end_state = state;
  453. } else
  454. {
  455. end_state = TAP_IRSHIFT;
  456. }
  457. int found = 0;
  458. scan_size = tap->ir_length;
  459. /* search the list */
  460. for (j = 0; j < num_fields; j++)
  461. {
  462. if (tap == fields[j].tap)
  463. {
  464. found = 1;
  465. scanFields(1, fields + j, TAP_IRSHIFT, end_state);
  466. /* update device information */
  467. buf_cpy(fields[j].out_value, tap->cur_instr, scan_size);
  468. tap->bypass = 0;
  469. break;
  470. }
  471. }
  472. if (!found)
  473. {
  474. /* if a device isn't listed, set it to BYPASS */
  475. uint8_t ones[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
  476. scan_field_t tmp;
  477. memset(&tmp, 0, sizeof(tmp));
  478. tmp.out_value = ones;
  479. tmp.num_bits = scan_size;
  480. scanFields(1, &tmp, TAP_IRSHIFT, end_state);
  481. /* update device information */
  482. buf_cpy(tmp.out_value, tap->cur_instr, scan_size);
  483. tap->bypass = 1;
  484. }
  485. }
  486. return ERROR_OK;
  487. }
  488. int interface_jtag_add_plain_ir_scan(int num_fields, const scan_field_t *fields, tap_state_t state)
  489. {
  490. scanFields(num_fields, fields, TAP_IRSHIFT, state);
  491. return ERROR_OK;
  492. }
  493. /*extern jtag_command_t **jtag_get_last_command_p(void);*/
  494. int interface_jtag_add_dr_scan(int num_fields, const scan_field_t *fields, tap_state_t state)
  495. {
  496. int j;
  497. jtag_tap_t *tap, *nextTap;
  498. for (tap = jtag_tap_next_enabled(NULL); tap!= NULL; tap = nextTap)
  499. {
  500. nextTap = jtag_tap_next_enabled(tap);
  501. int found = 0;
  502. tap_state_t end_state;
  503. if (nextTap == NULL)
  504. {
  505. end_state = state;
  506. } else
  507. {
  508. end_state = TAP_DRSHIFT;
  509. }
  510. for (j = 0; j < num_fields; j++)
  511. {
  512. if (tap == fields[j].tap)
  513. {
  514. found = 1;
  515. scanFields(1, fields + j, TAP_DRSHIFT, end_state);
  516. }
  517. }
  518. if (!found)
  519. {
  520. scan_field_t tmp;
  521. /* program the scan field to 1 bit length, and ignore it's value */
  522. tmp.num_bits = 1;
  523. tmp.out_value = NULL;
  524. tmp.in_value = NULL;
  525. scanFields(1, &tmp, TAP_DRSHIFT, end_state);
  526. }
  527. else
  528. {
  529. }
  530. }
  531. return ERROR_OK;
  532. }
  533. int interface_jtag_add_plain_dr_scan(int num_fields, const scan_field_t *fields, tap_state_t state)
  534. {
  535. scanFields(num_fields, fields, TAP_DRSHIFT, state);
  536. return ERROR_OK;
  537. }
  538. int interface_jtag_add_tlr()
  539. {
  540. setCurrentState(TAP_RESET);
  541. return ERROR_OK;
  542. }
  543. extern int jtag_nsrst_delay;
  544. extern int jtag_ntrst_delay;
  545. int interface_jtag_add_reset(int req_trst, int req_srst)
  546. {
  547. zy1000_reset(req_trst, req_srst);
  548. return ERROR_OK;
  549. }
  550. static int zy1000_jtag_add_clocks(int num_cycles, tap_state_t state, tap_state_t clockstate)
  551. {
  552. /* num_cycles can be 0 */
  553. setCurrentState(clockstate);
  554. /* execute num_cycles, 32 at the time. */
  555. int i;
  556. for (i = 0; i < num_cycles; i += 32)
  557. {
  558. int num;
  559. num = 32;
  560. if (num_cycles-i < num)
  561. {
  562. num = num_cycles-i;
  563. }
  564. shiftValueInner(clockstate, clockstate, num, 0);
  565. }
  566. #if !TEST_MANUAL()
  567. /* finish in end_state */
  568. setCurrentState(state);
  569. #else
  570. tap_state_t t = TAP_IDLE;
  571. /* test manual drive code on any target */
  572. int tms;
  573. uint8_t tms_scan = tap_get_tms_path(t, state);
  574. int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
  575. for (i = 0; i < tms_count; i++)
  576. {
  577. tms = (tms_scan >> i) & 1;
  578. waitIdle();
  579. ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, tms);
  580. }
  581. waitIdle();
  582. ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, state);
  583. #endif
  584. return ERROR_OK;
  585. }
  586. int interface_jtag_add_runtest(int num_cycles, tap_state_t state)
  587. {
  588. return zy1000_jtag_add_clocks(num_cycles, state, TAP_IDLE);
  589. }
  590. int interface_jtag_add_clocks(int num_cycles)
  591. {
  592. return zy1000_jtag_add_clocks(num_cycles, cmd_queue_cur_state, cmd_queue_cur_state);
  593. }
  594. int interface_jtag_add_sleep(uint32_t us)
  595. {
  596. jtag_sleep(us);
  597. return ERROR_OK;
  598. }
  599. int interface_jtag_add_pathmove(int num_states, const tap_state_t *path)
  600. {
  601. int state_count;
  602. int tms = 0;
  603. /*wait for the fifo to be empty*/
  604. waitIdle();
  605. state_count = 0;
  606. tap_state_t cur_state = cmd_queue_cur_state;
  607. while (num_states)
  608. {
  609. if (tap_state_transition(cur_state, false) == path[state_count])
  610. {
  611. tms = 0;
  612. }
  613. else if (tap_state_transition(cur_state, true) == path[state_count])
  614. {
  615. tms = 1;
  616. }
  617. else
  618. {
  619. LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(cur_state), tap_state_name(path[state_count]));
  620. exit(-1);
  621. }
  622. waitIdle();
  623. ZY1000_POKE(ZY1000_JTAG_BASE + 0x28, tms);
  624. cur_state = path[state_count];
  625. state_count++;
  626. num_states--;
  627. }
  628. waitIdle();
  629. ZY1000_POKE(ZY1000_JTAG_BASE + 0x20, cur_state);
  630. return ERROR_OK;
  631. }
  632. void embeddedice_write_dcc(jtag_tap_t *tap, int reg_addr, uint8_t *buffer, int little, int count)
  633. {
  634. // static int const reg_addr = 0x5;
  635. tap_state_t end_state = jtag_get_end_state();
  636. if (jtag_tap_next_enabled(jtag_tap_next_enabled(NULL)) == NULL)
  637. {
  638. /* better performance via code duplication */
  639. if (little)
  640. {
  641. int i;
  642. for (i = 0; i < count; i++)
  643. {
  644. shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, fast_target_buffer_get_u32(buffer, 1));
  645. shiftValueInner(TAP_DRSHIFT, end_state, 6, reg_addr | (1 << 5));
  646. buffer += 4;
  647. }
  648. } else
  649. {
  650. int i;
  651. for (i = 0; i < count; i++)
  652. {
  653. shiftValueInner(TAP_DRSHIFT, TAP_DRSHIFT, 32, fast_target_buffer_get_u32(buffer, 0));
  654. shiftValueInner(TAP_DRSHIFT, end_state, 6, reg_addr | (1 << 5));
  655. buffer += 4;
  656. }
  657. }
  658. }
  659. else
  660. {
  661. int i;
  662. for (i = 0; i < count; i++)
  663. {
  664. embeddedice_write_reg_inner(tap, reg_addr, fast_target_buffer_get_u32(buffer, little));
  665. buffer += 4;
  666. }
  667. }
  668. }