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.
 
 
 
 
 
 

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