Browse Source

Change tap_state naming to be consistent with SVF documentation.

Courtesy of Dick Hollenbeck <dick@softplc.com>


git-svn-id: svn://svn.berlios.de/openocd/trunk@1232 b42882b7-edfa-0310-969c-e2dbd0fdcd60
tags/v0.1.0
kc8apf 14 years ago
parent
commit
c45de8073d
30 changed files with 1463 additions and 1468 deletions
  1. +32
    -32
      src/flash/str9xpec.c
  2. +53
    -53
      src/jtag/amt_jtagaccel.c
  3. +39
    -39
      src/jtag/bitbang.c
  4. +6
    -6
      src/jtag/bitq.c
  5. +203
    -203
      src/jtag/ft2232.c
  6. +49
    -49
      src/jtag/gw16012.c
  7. +111
    -111
      src/jtag/jlink.c
  8. +37
    -37
      src/jtag/jtag.c
  9. +14
    -19
      src/jtag/jtag.h
  10. +7
    -7
      src/jtag/usbprog.c
  11. +19
    -19
      src/jtag/zy1000.c
  12. +8
    -8
      src/pld/virtex2.c
  13. +8
    -8
      src/target/arm11.c
  14. +30
    -30
      src/target/arm11_dbgtap.c
  15. +68
    -68
      src/target/arm720t.c
  16. +4
    -4
      src/target/arm7_9_common.c
  17. +86
    -86
      src/target/arm7tdmi.c
  18. +201
    -201
      src/target/arm920t.c
  19. +3
    -3
      src/target/arm926ejs.c
  20. +26
    -26
      src/target/arm966e.c
  21. +106
    -106
      src/target/arm9tdmi.c
  22. +124
    -124
      src/target/cortex_swjdp.c
  23. +5
    -5
      src/target/embeddedice.c
  24. +3
    -3
      src/target/etb.c
  25. +2
    -2
      src/target/etm.c
  26. +37
    -37
      src/target/feroceon.c
  27. +3
    -3
      src/target/mips_ejtag.c
  28. +109
    -109
      src/target/mips_m4k.c
  29. +32
    -32
      src/target/xscale.c
  30. +38
    -38
      src/xsvf/xsvf.c

+ 32
- 32
src/flash/str9xpec.c View File

@@ -145,7 +145,7 @@ u8 str9xpec_isc_status(jtag_tap_t *tap)
scan_field_t field;
u8 status;

if (str9xpec_set_instr(tap, ISC_NOOP, TAP_PI) != ERROR_OK)
if (str9xpec_set_instr(tap, ISC_NOOP, TAP_IRPAUSE) != ERROR_OK)
return ISC_STATUS_ERROR;

field.tap = tap;
@@ -158,7 +158,7 @@ u8 str9xpec_isc_status(jtag_tap_t *tap)
field.in_handler = NULL;
field.in_handler_priv = NULL;

jtag_add_dr_scan(1, &field, TAP_RTI);
jtag_add_dr_scan(1, &field, TAP_IDLE);
jtag_execute_queue();

LOG_DEBUG("status: 0x%2.2x", status);
@@ -181,7 +181,7 @@ int str9xpec_isc_enable(struct flash_bank_s *bank)
return ERROR_OK;

/* enter isc mode */
if (str9xpec_set_instr(tap, ISC_ENABLE, TAP_RTI) != ERROR_OK)
if (str9xpec_set_instr(tap, ISC_ENABLE, TAP_IDLE) != ERROR_OK)
return ERROR_TARGET_INVALID;

/* check ISC status */
@@ -207,7 +207,7 @@ int str9xpec_isc_disable(struct flash_bank_s *bank)
if (!str9xpec_info->isc_enable)
return ERROR_OK;

if (str9xpec_set_instr(tap, ISC_DISABLE, TAP_RTI) != ERROR_OK)
if (str9xpec_set_instr(tap, ISC_DISABLE, TAP_IDLE) != ERROR_OK)
return ERROR_TARGET_INVALID;

/* delay to handle aborts */
@@ -238,7 +238,7 @@ int str9xpec_read_config(struct flash_bank_s *bank)
LOG_DEBUG("ISC_CONFIGURATION");

/* execute ISC_CONFIGURATION command */
str9xpec_set_instr(tap, ISC_CONFIGURATION, TAP_PI);
str9xpec_set_instr(tap, ISC_CONFIGURATION, TAP_IRPAUSE);

field.tap = tap;
field.num_bits = 64;
@@ -250,7 +250,7 @@ int str9xpec_read_config(struct flash_bank_s *bank)
field.in_handler = NULL;
field.in_handler_priv = NULL;

jtag_add_dr_scan(1, &field, TAP_RTI);
jtag_add_dr_scan(1, &field, TAP_IDLE);
jtag_execute_queue();

status = str9xpec_isc_status(tap);
@@ -349,10 +349,10 @@ int str9xpec_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, ch
armv4_5 = bank->target->arch_info;
arm7_9 = armv4_5->arch_info;
jtag_info = &arm7_9->jtag_info;
str9xpec_info->tap = jtag_TapByAbsPosition( jtag_info->tap->abs_chain_position - 1);
str9xpec_info->isc_enable = 0;
str9xpec_build_block_list(bank);

/* clear option byte register */
@@ -390,7 +390,7 @@ int str9xpec_blank_check(struct flash_bank_s *bank, int first, int last)
}

/* execute ISC_BLANK_CHECK command */
str9xpec_set_instr(tap, ISC_BLANK_CHECK, TAP_PI);
str9xpec_set_instr(tap, ISC_BLANK_CHECK, TAP_IRPAUSE);

field.tap = tap;
field.num_bits = 64;
@@ -402,7 +402,7 @@ int str9xpec_blank_check(struct flash_bank_s *bank, int first, int last)
field.in_handler = NULL;
field.in_handler_priv = NULL;

jtag_add_dr_scan(1, &field, TAP_RTI);
jtag_add_dr_scan(1, &field, TAP_IDLE);
jtag_add_sleep(40000);

/* read blank check result */
@@ -416,7 +416,7 @@ int str9xpec_blank_check(struct flash_bank_s *bank, int first, int last)
field.in_handler = NULL;
field.in_handler_priv = NULL;

jtag_add_dr_scan(1, &field, TAP_PI);
jtag_add_dr_scan(1, &field, TAP_IRPAUSE);
jtag_execute_queue();

status = str9xpec_isc_status(tap);
@@ -506,7 +506,7 @@ int str9xpec_erase_area(struct flash_bank_s *bank, int first, int last)
LOG_DEBUG("ISC_ERASE");

/* execute ISC_ERASE command */
str9xpec_set_instr(tap, ISC_ERASE, TAP_PI);
str9xpec_set_instr(tap, ISC_ERASE, TAP_IRPAUSE);

field.tap = tap;
field.num_bits = 64;
@@ -518,7 +518,7 @@ int str9xpec_erase_area(struct flash_bank_s *bank, int first, int last)
field.in_handler = NULL;
field.in_handler_priv = NULL;

jtag_add_dr_scan(1, &field, TAP_RTI);
jtag_add_dr_scan(1, &field, TAP_IDLE);
jtag_execute_queue();

jtag_add_sleep(10);
@@ -569,9 +569,9 @@ int str9xpec_lock_device(struct flash_bank_s *bank)
str9xpec_set_address(bank, 0x80);

/* execute ISC_PROGRAM command */
str9xpec_set_instr(tap, ISC_PROGRAM_SECURITY, TAP_RTI);
str9xpec_set_instr(tap, ISC_PROGRAM_SECURITY, TAP_IDLE);

str9xpec_set_instr(tap, ISC_NOOP, TAP_PI);
str9xpec_set_instr(tap, ISC_NOOP, TAP_IRPAUSE);

do {
field.tap = tap;
@@ -658,7 +658,7 @@ int str9xpec_set_address(struct flash_bank_s *bank, u8 sector)
tap = str9xpec_info->tap;

/* set flash controller address */
str9xpec_set_instr(tap, ISC_ADDRESS_SHIFT, TAP_PI);
str9xpec_set_instr(tap, ISC_ADDRESS_SHIFT, TAP_IRPAUSE);

field.tap = tap;
field.num_bits = 8;
@@ -747,7 +747,7 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)

while (dwords_remaining > 0)
{
str9xpec_set_instr(tap, ISC_PROGRAM, TAP_PI);
str9xpec_set_instr(tap, ISC_PROGRAM, TAP_IRPAUSE);

field.tap = tap;
field.num_bits = 64;
@@ -759,12 +759,12 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
field.in_handler = NULL;
field.in_handler_priv = NULL;

jtag_add_dr_scan(1, &field, TAP_RTI);
jtag_add_dr_scan(1, &field, TAP_IDLE);

/* small delay before polling */
jtag_add_sleep(50);

str9xpec_set_instr(tap, ISC_NOOP, TAP_PI);
str9xpec_set_instr(tap, ISC_NOOP, TAP_IRPAUSE);

do {
field.tap = tap;
@@ -807,7 +807,7 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
bytes_written++;
}

str9xpec_set_instr(tap, ISC_PROGRAM, TAP_PI);
str9xpec_set_instr(tap, ISC_PROGRAM, TAP_IRPAUSE);

field.tap = tap;
field.num_bits = 64;
@@ -819,12 +819,12 @@ int str9xpec_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
field.in_handler = NULL;
field.in_handler_priv = NULL;

jtag_add_dr_scan(1, &field, TAP_RTI);
jtag_add_dr_scan(1, &field, TAP_IDLE);

/* small delay before polling */
jtag_add_sleep(50);

str9xpec_set_instr(tap, ISC_NOOP, TAP_PI);
str9xpec_set_instr(tap, ISC_NOOP, TAP_IRPAUSE);

do {
field.tap = tap;
@@ -889,7 +889,7 @@ int str9xpec_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd

buffer = calloc(CEIL(32, 8), 1);

str9xpec_set_instr(tap, ISC_IDCODE, TAP_PI);
str9xpec_set_instr(tap, ISC_IDCODE, TAP_IRPAUSE);

field.tap = tap;
field.num_bits = 32;
@@ -901,7 +901,7 @@ int str9xpec_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd
field.in_handler = NULL;
field.in_handler_priv = NULL;

jtag_add_dr_scan(1, &field, TAP_RTI);
jtag_add_dr_scan(1, &field, TAP_IDLE);
jtag_execute_queue();

idcode = buf_get_u32(buffer, 0, 32);
@@ -1014,7 +1014,7 @@ int str9xpec_write_options(struct flash_bank_s *bank)
str9xpec_set_address(bank, 0x50);

/* execute ISC_PROGRAM command */
str9xpec_set_instr(tap, ISC_PROGRAM, TAP_PI);
str9xpec_set_instr(tap, ISC_PROGRAM, TAP_IRPAUSE);

field.tap = tap;
field.num_bits = 64;
@@ -1026,12 +1026,12 @@ int str9xpec_write_options(struct flash_bank_s *bank)
field.in_handler = NULL;
field.in_handler_priv = NULL;

jtag_add_dr_scan(1, &field, TAP_RTI);
jtag_add_dr_scan(1, &field, TAP_IDLE);

/* small delay before polling */
jtag_add_sleep(50);

str9xpec_set_instr(tap, ISC_NOOP, TAP_PI);
str9xpec_set_instr(tap, ISC_NOOP, TAP_IRPAUSE);

do {
field.tap = tap;
@@ -1303,13 +1303,13 @@ int str9xpec_handle_flash_enable_turbo_command(struct command_context_s *cmd_ctx
}

/* enable turbo mode - TURBO-PROG-ENABLE */
str9xpec_set_instr(tap2, 0xD, TAP_RTI);
str9xpec_set_instr(tap2, 0xD, TAP_IDLE);
if ((retval = jtag_execute_queue()) != ERROR_OK)
return retval;

/* modify scan chain - str9 core has been removed */
tap1->enabled = 0;
return ERROR_OK;
}

@@ -1337,11 +1337,11 @@ int str9xpec_handle_flash_disable_turbo_command(struct command_context_s *cmd_ct

if (tap == NULL)
return ERROR_FAIL;
/* exit turbo mode via TLR */
str9xpec_set_instr(tap, ISC_NOOP, TAP_TLR);
str9xpec_set_instr(tap, ISC_NOOP, TAP_RESET);
jtag_execute_queue();
/* restore previous scan chain */
if (tap->next_tap) {
tap->next_tap->enabled = 1;


+ 53
- 53
src/jtag/amt_jtagaccel.c View File

@@ -109,13 +109,13 @@ u8 amt_jtagaccel_tap_move[6][6][2] =
{{0x1f, 0x00}, {0x0c, 0x00}, {0x07, 0x00}, {0x97, 0x00}, {0x08, 0x00}, {0x00, 0x00}}, /* PI */
};

jtag_interface_t amt_jtagaccel_interface =
jtag_interface_t amt_jtagaccel_interface =
{
.name = "amt_jtagaccel",
.execute_queue = amt_jtagaccel_execute_queue,

.speed = amt_jtagaccel_speed,
.speed = amt_jtagaccel_speed,
.register_commands = amt_jtagaccel_register_commands,
.init = amt_jtagaccel_init,
.quit = amt_jtagaccel_quit,
@@ -127,7 +127,7 @@ int amt_jtagaccel_register_commands(struct command_context_s *cmd_ctx)
COMMAND_CONFIG, NULL);
register_command(cmd_ctx, NULL, "rtck", amt_jtagaccel_handle_rtck_command,
COMMAND_CONFIG, NULL);
return ERROR_OK;
}

@@ -142,7 +142,7 @@ void amt_jtagaccel_reset(int trst, int srst)
aw_control_rst |= 0x1;
else if (srst == 0)
aw_control_rst &= ~0x1;
AMT_AW(aw_control_rst);
}

@@ -151,7 +151,7 @@ int amt_jtagaccel_speed(int speed)
aw_control_baudrate &= 0xf0;
aw_control_baudrate |= speed & 0x0f;
AMT_AW(aw_control_baudrate);
return ERROR_OK;
}

@@ -170,11 +170,11 @@ void amt_wait_scan_busy(void)
{
int timeout = 4096;
u8 ar_status;
AMT_AR(ar_status);
while (((ar_status) & 0x80) && (timeout-- > 0))
AMT_AR(ar_status);
if (ar_status & 0x80)
{
LOG_ERROR("amt_jtagaccel timed out while waiting for end of scan, rtck was %s, last AR_STATUS: 0x%2.2x", (rtck_enabled) ? "enabled" : "disabled", ar_status);
@@ -186,15 +186,15 @@ void amt_jtagaccel_state_move(void)
{
u8 aw_scan_tms_5;
u8 tms_scan[2];
tms_scan[0] = amt_jtagaccel_tap_move[tap_move_map[cur_state]][tap_move_map[end_state]][0];
tms_scan[1] = amt_jtagaccel_tap_move[tap_move_map[cur_state]][tap_move_map[end_state]][1];
aw_scan_tms_5 = 0x40 | (tms_scan[0] & 0x1f);
AMT_AW(aw_scan_tms_5);
if (jtag_speed > 3 || rtck_enabled)
amt_wait_scan_busy();
if (tms_scan[0] & 0x80)
{
aw_scan_tms_5 = 0x40 | (tms_scan[1] & 0x1f);
@@ -202,7 +202,7 @@ void amt_jtagaccel_state_move(void)
if (jtag_speed > 3 || rtck_enabled)
amt_wait_scan_busy();
}
cur_state = end_state;
}

@@ -213,27 +213,27 @@ void amt_jtagaccel_runtest(int num_cycles)
u8 aw_scan_tms_1to4;

enum tap_state saved_end_state = end_state;
/* only do a state_move when we're not already in RTI */
if (cur_state != TAP_RTI)
if (cur_state != TAP_IDLE)
{
amt_jtagaccel_end_state(TAP_RTI);
amt_jtagaccel_end_state(TAP_IDLE);
amt_jtagaccel_state_move();
}
while (num_cycles - i >= 5)
{
aw_scan_tms_5 = 0x40;
AMT_AW(aw_scan_tms_5);
i += 5;
}
if (num_cycles - i > 0)
{
aw_scan_tms_1to4 = 0x80 | ((num_cycles - i - 1) & 0x3) << 4;
AMT_AW(aw_scan_tms_1to4);
}
amt_jtagaccel_end_state(saved_end_state);
if (cur_state != end_state)
amt_jtagaccel_state_move();
@@ -251,9 +251,9 @@ void amt_jtagaccel_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_s
u8 tms_scan[2];

if (ir_scan)
amt_jtagaccel_end_state(TAP_SI);
amt_jtagaccel_end_state(TAP_IRSHIFT);
else
amt_jtagaccel_end_state(TAP_SD);
amt_jtagaccel_end_state(TAP_DRSHIFT);

amt_jtagaccel_state_move();
amt_jtagaccel_end_state(saved_end_state);
@@ -263,7 +263,7 @@ void amt_jtagaccel_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_s
{
aw_tdi_option = 0x30 | (((scan_size - 1) % 8) - 1);
AMT_AW(aw_tdi_option);
dw_tdi_scan = buf_get_u32(buffer, bit_count, (scan_size - 1) % 8) & 0xff;
AMT_DW(dw_tdi_scan);
if (jtag_speed > 3 || rtck_enabled)
@@ -275,11 +275,11 @@ void amt_jtagaccel_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_s
dr_tdo = dr_tdo >> (8 - ((scan_size - 1) % 8));
buf_set_u32(buffer, bit_count, (scan_size - 1) % 8, dr_tdo);
}
bit_count += (scan_size - 1) % 8;
bits_left -= (scan_size - 1) % 8;
}
while (bits_left - 1 >= 8)
{
dw_tdi_scan = buf_get_u32(buffer, bit_count, 8) & 0xff;
@@ -292,11 +292,11 @@ void amt_jtagaccel_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_s
AMT_DR(dr_tdo);
buf_set_u32(buffer, bit_count, 8, dr_tdo);
}
bit_count += 8;
bits_left -= 8;
}
tms_scan[0] = amt_jtagaccel_tap_move[tap_move_map[cur_state]][tap_move_map[end_state]][0];
tms_scan[1] = amt_jtagaccel_tap_move[tap_move_map[cur_state]][tap_move_map[end_state]][1];
aw_tms_scan = 0x40 | (tms_scan[0] & 0x1f) | (buf_get_u32(buffer, bit_count, 1) << 5);
@@ -310,7 +310,7 @@ void amt_jtagaccel_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_s
dr_tdo = dr_tdo >> 7;
buf_set_u32(buffer, bit_count, 1, dr_tdo);
}
if (tms_scan[0] & 0x80)
{
aw_tms_scan = 0x40 | (tms_scan[1] & 0x1f);
@@ -328,12 +328,12 @@ int amt_jtagaccel_execute_queue(void)
enum scan_type type;
u8 *buffer;
int retval;
/* return ERROR_OK, unless a jtag_read_buffer returns a failed check
* that wasn't handled by a caller-provided error handler
*/
*/
retval = ERROR_OK;
while (cmd)
{
switch (cmd->type)
@@ -351,7 +351,7 @@ int amt_jtagaccel_execute_queue(void)
#endif
if (cmd->cmd.reset->trst == 1)
{
cur_state = TAP_TLR;
cur_state = TAP_RESET;
}
amt_jtagaccel_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
@@ -397,7 +397,7 @@ int amt_jtagaccel_execute_queue(void)
}
cmd = cmd->next;
}
return retval;
}

@@ -409,16 +409,16 @@ int amt_jtagaccel_get_giveio_access(void)

version.dwOSVersionInfoSize = sizeof version;
if (!GetVersionEx( &version )) {
errno = EINVAL;
return -1;
errno = EINVAL;
return -1;
}
if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
return 0;
return 0;

h = CreateFile( "\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if (h == INVALID_HANDLE_VALUE) {
errno = ENODEV;
return -1;
errno = ENODEV;
return -1;
}

CloseHandle( h );
@@ -437,7 +437,7 @@ int amt_jtagaccel_init(void)
u8 status_port;
#endif
u8 ar_status;
#if PARPORT_USE_PPDEV == 1
if (device_handle > 0)
{
@@ -447,7 +447,7 @@ int amt_jtagaccel_init(void)

snprintf(buffer, 256, "/dev/parport%d", amt_jtagaccel_port);
device_handle = open(buffer, O_RDWR);
if (device_handle < 0)
{
LOG_ERROR("cannot open device. check it exists and that user read and write rights are set");
@@ -468,7 +468,7 @@ int amt_jtagaccel_init(void)
LOG_ERROR(" cannot set compatible mode to device");
return ERROR_JTAG_INIT_FAILED;
}
control_port = 0x00;
i = ioctl(device_handle, PPWCONTROL, &control_port);

@@ -484,57 +484,57 @@ int amt_jtagaccel_init(void)

#if PARPORT_USE_GIVEIO == 1
if (amt_jtagaccel_get_giveio_access() != 0) {
#else /* PARPORT_USE_GIVEIO */
#else /* PARPORT_USE_GIVEIO */
if (ioperm(amt_jtagaccel_port, 5, 1) != 0) {
#endif /* PARPORT_USE_GIVEIO */
LOG_ERROR("missing privileges for direct i/o");
return ERROR_JTAG_INIT_FAILED;
}
/* prepare epp port */
/* clear timeout */
status_port = inb(amt_jtagaccel_port + 1);
outb(status_port | 0x1, amt_jtagaccel_port + 1);
/* reset epp port */
outb(0x00, amt_jtagaccel_port + 2);
outb(0x04, amt_jtagaccel_port + 2);
#endif
if (rtck_enabled)
{
{
/* set RTCK enable bit */
aw_control_fsm |= 0x02;
}
/* enable JTAG port */
aw_control_fsm |= 0x04;
AMT_AW(aw_control_fsm);
amt_jtagaccel_speed(jtag_speed);
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
aw_control_rst &= ~0x8;
else
aw_control_rst |= 0x8;
if (jtag_reset_config & RESET_SRST_PUSH_PULL)
aw_control_rst &= ~0x2;
else
aw_control_rst |= 0x2;
amt_jtagaccel_reset(0, 0);
/* read status register */
AMT_AR(ar_status);
LOG_DEBUG("AR_STATUS: 0x%2.2x", ar_status);
return ERROR_OK;
}

int amt_jtagaccel_quit(void)
{
return ERROR_OK;
}

@@ -568,6 +568,6 @@ int amt_jtagaccel_handle_rtck_command(struct command_context_s *cmd_ctx, char *c
rtck_enabled = 0;
}
}
return ERROR_OK;
}

+ 39
- 39
src/jtag/bitbang.c View File

@@ -41,24 +41,24 @@ bitbang_interface_t *bitbang_interface;


/* DANGER!!!! clock absolutely *MUST* be 0 in idle or reset won't work!
*
*
* Set this to 1 and str912 reset halt will fail.
*
*
* If someone can submit a patch with an explanation it will be greatly
* appreciated, but as far as I can tell (ร˜H) DCLK is generated upon
* clk=0 in TAP_RTI. Good luck deducing that from the ARM documentation!
* The ARM documentation uses the term "DCLK is asserted while in the TAP_RTI
* clk=0 in TAP_IDLE. Good luck deducing that from the ARM documentation!
* The ARM documentation uses the term "DCLK is asserted while in the TAP_IDLE
* state". With hardware there is no such thing as *while* in a state. There
* are only edges. So clk => 0 is in fact a very subtle state transition that
* happens *while* in the TAP_RTI state. "#&ยค"#ยค&"#&"#&
*
* happens *while* in the TAP_IDLE state. "#&ยค"#ยค&"#&"#&
*
* For "reset halt" the last thing that happens before srst is asserted
* is that the breakpoint is set up. If DCLK is not wiggled one last
* time before the reset, then the breakpoint is not set up and
* "reset halt" will fail to halt.
*
*
*/
#define CLOCK_IDLE() 0
#define CLOCK_IDLE() 0

int bitbang_execute_queue(void);

@@ -76,10 +76,10 @@ void bitbang_end_state(enum tap_state state)
}

void bitbang_state_move(void) {
int i=0, tms=0;
u8 tms_scan = TAP_MOVE(cur_state, end_state);
for (i = 0; i < 7; i++)
{
tms = (tms_scan >> i) & 1;
@@ -87,7 +87,7 @@ void bitbang_state_move(void) {
bitbang_interface->write(1, tms, 0);
}
bitbang_interface->write(CLOCK_IDLE(), tms, 0);
cur_state = end_state;
}

@@ -113,7 +113,7 @@ void bitbang_path_move(pathmove_command_t *cmd)
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]);
exit(-1);
}
bitbang_interface->write(0, tms, 0);
bitbang_interface->write(1, tms, 0);

@@ -121,7 +121,7 @@ void bitbang_path_move(pathmove_command_t *cmd)
state_count++;
num_states--;
}
bitbang_interface->write(CLOCK_IDLE(), tms, 0);

end_state = cur_state;
@@ -130,16 +130,16 @@ void bitbang_path_move(pathmove_command_t *cmd)
void bitbang_runtest(int num_cycles)
{
int i;
enum tap_state saved_end_state = end_state;
/* only do a state_move when we're not already in RTI */
if (cur_state != TAP_RTI)
if (cur_state != TAP_IDLE)
{
bitbang_end_state(TAP_RTI);
bitbang_end_state(TAP_IDLE);
bitbang_state_move();
}
/* execute num_cycles */
for (i = 0; i < num_cycles; i++)
{
@@ -147,7 +147,7 @@ void bitbang_runtest(int num_cycles)
bitbang_interface->write(1, 0, 0);
}
bitbang_interface->write(CLOCK_IDLE(), 0, 0);
/* finish in end_state */
bitbang_end_state(saved_end_state);
if (cur_state != end_state)
@@ -158,13 +158,13 @@ void bitbang_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
{
enum tap_state saved_end_state = end_state;
int bit_cnt;
if (!((!ir_scan && (cur_state == TAP_SD)) || (ir_scan && (cur_state == TAP_SI))))
if (!((!ir_scan && (cur_state == TAP_DRSHIFT)) || (ir_scan && (cur_state == TAP_IRSHIFT))))
{
if (ir_scan)
bitbang_end_state(TAP_SI);
bitbang_end_state(TAP_IRSHIFT);
else
bitbang_end_state(TAP_SD);
bitbang_end_state(TAP_DRSHIFT);

bitbang_state_move();
bitbang_end_state(saved_end_state);
@@ -181,7 +181,7 @@ void bitbang_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
/* if we're just reading the scan, but don't care about the output
* default to outputting 'low', this also makes valgrind traces more readable,
* as it removes the dependency on an uninitialised value
*/
*/
tdi=0;
if ((type != SCAN_IN) && (buffer[bytec] & bcval))
tdi=1;
@@ -192,7 +192,7 @@ void bitbang_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
val=bitbang_interface->read();

bitbang_interface->write(1, tms, tdi);
if (type != SCAN_OUT)
{
if (val)
@@ -201,21 +201,21 @@ void bitbang_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
buffer[bytec] &= ~bcval;
}
}
/* TAP_SD & TAP_SI are illegal end states, so we always transition to the pause
/* TAP_DRSHIFT & TAP_IRSHIFT are illegal end states, so we always transition to the pause
* state which is a legal stable state from which statemove will work.
*
* Exit1 -> Pause
*
* Exit1 -> Pause
*/
bitbang_interface->write(0, 0, 0);
bitbang_interface->write(1, 0, 0);
bitbang_interface->write(CLOCK_IDLE(), 0, 0);
if (ir_scan)
cur_state = TAP_PI;
cur_state = TAP_IRPAUSE;
else
cur_state = TAP_PD;
cur_state = TAP_DRPAUSE;
if (cur_state != end_state)
bitbang_state_move();
}
@@ -227,18 +227,18 @@ int bitbang_execute_queue(void)
enum scan_type type;
u8 *buffer;
int retval;
if (!bitbang_interface)
{
LOG_ERROR("BUG: Bitbang interface called, but not yet initialized");
exit(-1);
}
/* return ERROR_OK, unless a jtag_read_buffer returns a failed check
* that wasn't handled by a caller-provided error handler
*/
*/
retval = ERROR_OK;
if(bitbang_interface->blink)
bitbang_interface->blink(1);

@@ -259,7 +259,7 @@ int bitbang_execute_queue(void)
#endif
if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_reset_config & RESET_SRST_PULLS_TRST)))
{
cur_state = TAP_TLR;
cur_state = TAP_RESET;
}
bitbang_interface->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
@@ -313,7 +313,7 @@ int bitbang_execute_queue(void)
}
if(bitbang_interface->blink)
bitbang_interface->blink(0);
return retval;
}


+ 6
- 6
src/jtag/bitq.c View File

@@ -195,7 +195,7 @@ void bitq_runtest(int num_cycles)
int i;

/* only do a state_move when we're not already in RTI */
if (cur_state != TAP_RTI) bitq_state_move(TAP_RTI);
if (cur_state != TAP_IDLE) bitq_state_move(TAP_IDLE);

/* execute num_cycles */
for (i = 0; i < num_cycles; i++)
@@ -240,8 +240,8 @@ void bitq_scan_field(scan_field_t *field, int pause)

if (pause) {
bitq_io(0,0,0);
if (cur_state==TAP_SI) cur_state=TAP_PI;
else if (cur_state==TAP_SD) cur_state=TAP_PD;
if (cur_state==TAP_IRSHIFT) cur_state=TAP_IRPAUSE;
else if (cur_state==TAP_DRSHIFT) cur_state=TAP_DRPAUSE;
}
}

@@ -250,8 +250,8 @@ void bitq_scan(scan_command_t *cmd)
{
int i;

if (cmd->ir_scan) bitq_state_move(TAP_SI);
else bitq_state_move(TAP_SD);
if (cmd->ir_scan) bitq_state_move(TAP_IRSHIFT);
else bitq_state_move(TAP_DRSHIFT);

for (i=0; i < cmd->num_fields-1; i++)
bitq_scan_field(&cmd->fields[i], 0);
@@ -285,7 +285,7 @@ int bitq_execute_queue(void)
#endif
if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_reset_config & RESET_SRST_PULLS_TRST)))
{
cur_state = TAP_TLR;
cur_state = TAP_RESET;
}
bitq_interface->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
if (bitq_interface->in_rdy()) bitq_in_proc();


+ 203
- 203
src/jtag/ft2232.c
File diff suppressed because it is too large
View File


+ 49
- 49
src/jtag/gw16012.c View File

@@ -97,13 +97,13 @@ int gw16012_quit(void);

int gw16012_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);

jtag_interface_t gw16012_interface =
jtag_interface_t gw16012_interface =
{
.name = "gw16012",
.execute_queue = gw16012_execute_queue,

.speed = gw16012_speed,
.speed = gw16012_speed,
.register_commands = gw16012_register_commands,
.init = gw16012_init,
.quit = gw16012_quit,
@@ -113,7 +113,7 @@ int gw16012_register_commands(struct command_context_s *cmd_ctx)
{
register_command(cmd_ctx, NULL, "parport_port", gw16012_handle_parport_port_command,
COMMAND_CONFIG, NULL);
return ERROR_OK;
}

@@ -125,7 +125,7 @@ void gw16012_data(u8 value)
#ifdef _DEBUG_GW16012_IO_
LOG_DEBUG("%2.2x", value);
#endif
#if PARPORT_USE_PPDEV == 1
ioctl(device_handle, PPWDATA, &value);
#else
@@ -134,7 +134,7 @@ void gw16012_data(u8 value)
#else
outb(value, gw16012_port);
#endif
#endif
#endif
}

void gw16012_control(u8 value)
@@ -209,15 +209,15 @@ void gw16012_state_move(void)
{
int i=0, tms=0;
u8 tms_scan = TAP_MOVE(cur_state, end_state);
gw16012_control(0x0); /* single-bit mode */
for (i = 0; i < 7; i++)
{
tms = (tms_scan >> i) & 1;
gw16012_data(tms << 1); /* output next TMS bit */
}
cur_state = end_state;
}

@@ -243,12 +243,12 @@ void gw16012_path_move(pathmove_command_t *cmd)
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[cmd->path[state_count]]);
exit(-1);
}
cur_state = cmd->path[state_count];
state_count++;
num_states--;
}
end_state = cur_state;
}

@@ -256,20 +256,20 @@ void gw16012_runtest(int num_cycles)
{
enum tap_state saved_end_state = end_state;
int i;
/* only do a state_move when we're not already in RTI */
if (cur_state != TAP_RTI)
if (cur_state != TAP_IDLE)
{
gw16012_end_state(TAP_RTI);
gw16012_end_state(TAP_IDLE);
gw16012_state_move();
}
for (i = 0; i < num_cycles; i++)
{
gw16012_control(0x0); /* single-bit mode */
gw16012_data(0x0); /* TMS cycle with TMS low */
}
gw16012_end_state(saved_end_state);
if (cur_state != end_state)
gw16012_state_move();
@@ -283,12 +283,12 @@ void gw16012_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
u8 scan_out, scan_in;

/* only if we're not already in the correct Shift state */
if (!((!ir_scan && (cur_state == TAP_SD)) || (ir_scan && (cur_state == TAP_SI))))
if (!((!ir_scan && (cur_state == TAP_DRSHIFT)) || (ir_scan && (cur_state == TAP_IRSHIFT))))
{
if (ir_scan)
gw16012_end_state(TAP_SI);
gw16012_end_state(TAP_IRSHIFT);
else
gw16012_end_state(TAP_SD);
gw16012_end_state(TAP_DRSHIFT);

gw16012_state_move();
gw16012_end_state(saved_end_state);
@@ -302,20 +302,20 @@ void gw16012_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
bit_count += 7;
bits_left -= 7;
}
gw16012_control(0x0); /* single-bit mode */
while (bits_left-- > 0)
{
u8 tms = 0;
scan_out = buf_get_u32(buffer, bit_count, 1);
if (bits_left == 0) /* last bit */
{
if ((ir_scan && (end_state == TAP_SI))
|| (!ir_scan && (end_state == TAP_SD)))
if ((ir_scan && (end_state == TAP_IRSHIFT))
|| (!ir_scan && (end_state == TAP_DRSHIFT)))
{
tms = 0;
tms = 0;
}
else
{
@@ -329,20 +329,20 @@ void gw16012_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
{
gw16012_input(&scan_in);
buf_set_u32(buffer, bit_count, 1, ((scan_in & 0x08) >> 3));
}
}

bit_count++;
}

if (!((ir_scan && (end_state == TAP_SI)) ||
(!ir_scan && (end_state == TAP_SD))))
if (!((ir_scan && (end_state == TAP_IRSHIFT)) ||
(!ir_scan && (end_state == TAP_DRSHIFT))))
{
gw16012_data(0x0);
if (ir_scan)
cur_state = TAP_PI;
cur_state = TAP_IRPAUSE;
else
cur_state = TAP_PD;
cur_state = TAP_DRPAUSE;
if (cur_state != end_state)
gw16012_state_move();
}
@@ -355,12 +355,12 @@ int gw16012_execute_queue(void)
enum scan_type type;
u8 *buffer;
int retval;
/* return ERROR_OK, unless a jtag_read_buffer returns a failed check
* that wasn't handled by a caller-provided error handler
*/
*/
retval = ERROR_OK;
while (cmd)
{
switch (cmd->type)
@@ -378,7 +378,7 @@ int gw16012_execute_queue(void)
#endif
if (cmd->cmd.reset->trst == 1)
{
cur_state = TAP_TLR;
cur_state = TAP_RESET;
}
gw16012_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
@@ -410,7 +410,7 @@ int gw16012_execute_queue(void)
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
type = jtag_scan_type(cmd->cmd.scan);
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("%s scan (%i) %i bit end in %i", (cmd->cmd.scan->ir_scan) ? "ir" : "dr",
LOG_DEBUG("%s scan (%i) %i bit end in %i", (cmd->cmd.scan->ir_scan) ? "ir" : "dr",
type, scan_size, cmd->cmd.scan->end_state);
#endif
gw16012_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size);
@@ -431,7 +431,7 @@ int gw16012_execute_queue(void)
}
cmd = cmd->next;
}
return retval;
}

@@ -443,16 +443,16 @@ int gw16012_get_giveio_access()

version.dwOSVersionInfoSize = sizeof version;
if (!GetVersionEx( &version )) {
errno = EINVAL;
return -1;
errno = EINVAL;
return -1;
}
if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
return 0;
return 0;

h = CreateFile( "\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if (h == INVALID_HANDLE_VALUE) {
errno = ENODEV;
return -1;
errno = ENODEV;
return -1;
}

CloseHandle( h );
@@ -468,7 +468,7 @@ int gw16012_init(void)
int i = 0;
#endif
u8 status_port;
#if PARPORT_USE_PPDEV == 1
if (device_handle>0)
{
@@ -486,7 +486,7 @@ int gw16012_init(void)

snprintf(buffer, 256, "/dev/parport%d", gw16012_port);
device_handle = open(buffer, O_WRONLY);
#endif
#endif
if (device_handle<0)
{
LOG_ERROR("cannot open device. check it exists and that user read and write rights are set");
@@ -525,7 +525,7 @@ int gw16012_init(void)
gw16012_port = 0x378;
LOG_WARNING("No gw16012 port specified, using default '0x378' (LPT1)");
}
LOG_DEBUG("requesting privileges for parallel port 0x%lx...", (long unsigned)(gw16012_port) );
#if PARPORT_USE_GIVEIO == 1
if (gw16012_get_giveio_access() != 0)
@@ -545,19 +545,19 @@ int gw16012_init(void)
outb(0x0, gw16012_port + 2);
#endif
#endif /* PARPORT_USE_PPDEV */
gw16012_input(&status_port);
gw16012_msb = (status_port & 0x80) ^ 0x80;
gw16012_speed(jtag_speed);
gw16012_reset(0, 0);
return ERROR_OK;
}

int gw16012_quit(void)
{
return ERROR_OK;
}



+ 111
- 111
src/jtag/jlink.c View File

@@ -146,92 +146,92 @@ int jlink_execute_queue(void)
int scan_size;
enum scan_type type;
u8 *buffer;
while (cmd != NULL)
{
switch (cmd->type)
{
case JTAG_END_STATE:
DEBUG_JTAG_IO("end_state: %i", cmd->cmd.end_state->end_state);
if (cmd->cmd.end_state->end_state != -1)
{
jlink_end_state(cmd->cmd.end_state->end_state);
}
break;
case JTAG_RUNTEST:
DEBUG_JTAG_IO( "runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, \
cmd->cmd.runtest->end_state);
if (cmd->cmd.runtest->end_state != -1)
{
jlink_end_state(cmd->cmd.runtest->end_state);
}
jlink_runtest(cmd->cmd.runtest->num_cycles);
break;
case JTAG_STATEMOVE:
DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
if (cmd->cmd.statemove->end_state != -1)
{
jlink_end_state(cmd->cmd.statemove->end_state);
}
jlink_state_move();
break;
case JTAG_PATHMOVE:
DEBUG_JTAG_IO("pathmove: %i states, end in %i", \
cmd->cmd.pathmove->num_states, \
cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
jlink_path_move(cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path);
break;
case JTAG_SCAN:
DEBUG_JTAG_IO("scan end in %i", cmd->cmd.scan->end_state);
if (cmd->cmd.scan->end_state != -1)
{
jlink_end_state(cmd->cmd.scan->end_state);
}
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
DEBUG_JTAG_IO("scan input, length = %d", scan_size);
#ifdef _DEBUG_USB_COMMS_
jlink_debug_buffer(buffer, (scan_size + 7) / 8);
#endif
type = jtag_scan_type(cmd->cmd.scan);
jlink_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size, cmd->cmd.scan);
break;
case JTAG_RESET:
DEBUG_JTAG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
jlink_tap_execute();
if (cmd->cmd.reset->trst == 1)
{
cur_state = TAP_TLR;
cur_state = TAP_RESET;
}
jlink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
break;
case JTAG_SLEEP:
DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us);
jlink_tap_execute();
jtag_sleep(cmd->cmd.sleep->us);
break;
default:
LOG_ERROR("BUG: unknown JTAG command type encountered");
exit(-1);
}
cmd = cmd->next;
}
return jlink_tap_execute();
}

@@ -239,19 +239,19 @@ int jlink_execute_queue(void)
int jlink_speed(int speed)
{
int result;
if (speed <= JLINK_MAX_SPEED)
{
/* check for RTCK setting */
if (speed == 0)
speed = -1;
usb_out_buffer[0] = EMU_CMD_SET_SPEED;
usb_out_buffer[1] = (speed >> 0) & 0xff;
usb_out_buffer[2] = (speed >> 8) & 0xff;
result = jlink_usb_write(jlink_jtag_handle, 3);
if (result == 3)
{
return ERROR_OK;
@@ -266,14 +266,14 @@ int jlink_speed(int speed)
{
LOG_INFO("Requested speed %dkHz exceeds maximum of %dkHz, ignored", speed, JLINK_MAX_SPEED);
}
return ERROR_OK;
}

int jlink_khz(int khz, int *jtag_speed)
{
*jtag_speed = khz;
return ERROR_OK;
}

@@ -286,16 +286,16 @@ int jlink_register_commands(struct command_context_s *cmd_ctx)

int jlink_init(void)
{
int check_cnt;
int check_cnt;
jlink_jtag_handle = jlink_usb_open();
if (jlink_jtag_handle == 0)
{
LOG_ERROR("Cannot find jlink Interface! Please check connection and permissions.");
return ERROR_JTAG_INIT_FAILED;
}
check_cnt = 0;
while (check_cnt < 3)
{
@@ -305,7 +305,7 @@ int jlink_init(void)
jlink_get_status();
break;
}
check_cnt++;
}

@@ -313,12 +313,12 @@ int jlink_init(void)
{
LOG_INFO("J-Link initial read failed, don't worry");
}
LOG_INFO("J-Link JTAG Interface ready");
jlink_reset(0, 0);
jlink_tap_init();
return ERROR_OK;
}

@@ -350,20 +350,20 @@ void jlink_state_move(void)
int i;
int tms = 0;
u8 tms_scan = TAP_MOVE(cur_state, end_state);
for (i = 0; i < 7; i++)
{
tms = (tms_scan >> i) & 1;
jlink_tap_append_step(tms, 0);
}
cur_state = end_state;
}

void jlink_path_move(int num_states, enum tap_state *path)
{
int i;
for (i = 0; i < num_states; i++)
{
if (path[i] == tap_transitions[cur_state].low)
@@ -379,32 +379,32 @@ void jlink_path_move(int num_states, enum tap_state *path)
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_strings[cur_state], tap_state_strings[path[i]]);
exit(-1);
}
cur_state = path[i];
}
end_state = cur_state;
}

void jlink_runtest(int num_cycles)
{
int i;
enum tap_state saved_end_state = end_state;
/* only do a state_move when we're not already in RTI */
if (cur_state != TAP_RTI)
if (cur_state != TAP_IDLE)
{
jlink_end_state(TAP_RTI);
jlink_end_state(TAP_IDLE);
jlink_state_move();
}
/* execute num_cycles */
for (i = 0; i < num_cycles; i++)
{
jlink_tap_append_step(0, 0);
}
/* finish in end_state */
jlink_end_state(saved_end_state);
if (cur_state != end_state)
@@ -416,25 +416,25 @@ void jlink_runtest(int num_cycles)
void jlink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command)
{
enum tap_state saved_end_state;
jlink_tap_ensure_space(1, scan_size + 8);
saved_end_state = end_state;
/* Move to appropriate scan state */
jlink_end_state(ir_scan ? TAP_SI : TAP_SD);
jlink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT);
jlink_state_move();
jlink_end_state(saved_end_state);
/* Scan */
jlink_tap_append_scan(scan_size, buffer, command);
/* We are in Exit1, go to Pause */
jlink_tap_append_step(0, 0);
cur_state = ir_scan ? TAP_PI : TAP_PD;
cur_state = ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE;
if (cur_state != end_state)
{
jlink_state_move();
@@ -444,7 +444,7 @@ void jlink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, sca
void jlink_reset(int trst, int srst)
{
LOG_DEBUG("trst: %i, srst: %i", trst, srst);
/* Signals are active low */
if (srst == 0)
{
@@ -454,7 +454,7 @@ void jlink_reset(int trst, int srst)
{
jlink_simple_command(EMU_CMD_HW_RESET0);
}
if (trst == 0)
{
jlink_simple_command(EMU_CMD_HW_TRST1);
@@ -468,12 +468,12 @@ void jlink_reset(int trst, int srst)
void jlink_simple_command(u8 command)
{
int result;
DEBUG_JTAG_IO("0x%02x", command);
usb_out_buffer[0] = command;
result = jlink_usb_write(jlink_jtag_handle, 1);
if (result != 1)
{
LOG_ERROR("J-Link command 0x%02x failed (%d)", command, result);
@@ -483,10 +483,10 @@ void jlink_simple_command(u8 command)
int jlink_get_status(void)
{
int result;
jlink_simple_command(EMU_CMD_GET_STATE);
result = jlink_usb_read(jlink_jtag_handle);
if (result == 8)
{
int vref = usb_in_buffer[0] + (usb_in_buffer[1] << 8);
@@ -494,7 +494,7 @@ int jlink_get_status(void)
vref / 1000, vref % 1000, \
usb_in_buffer[2], usb_in_buffer[3], usb_in_buffer[4], \
usb_in_buffer[5], usb_in_buffer[6], usb_in_buffer[7]);
if (vref < 1500)
{
LOG_ERROR("Vref too low. Check Target Power\n");
@@ -504,7 +504,7 @@ int jlink_get_status(void)
{
LOG_ERROR("J-Link command EMU_CMD_GET_STATE failed (%d)\n", result);
}
return ERROR_OK;
}

@@ -512,16 +512,16 @@ int jlink_get_version_info(void)
{
int result;
int len = 0;
/* query hardware version */
jlink_simple_command(EMU_CMD_VERSION);
result = jlink_usb_read(jlink_jtag_handle);
if (result == 2)
{
len = buf_get_u32(usb_in_buffer, 0, 16);
result = jlink_usb_read(jlink_jtag_handle);
if (result == len)
{
usb_in_buffer[result] = 0;
@@ -529,7 +529,7 @@ int jlink_get_version_info(void)
return ERROR_OK;
}
}
LOG_ERROR("J-Link command EMU_CMD_VERSION failed (%d)\n", result);
return ERROR_JTAG_DEVICE_ERROR;
}
@@ -541,7 +541,7 @@ int jlink_handle_jlink_info_command(struct command_context_s *cmd_ctx, char *cmd
/* attempt to get status */
jlink_get_status();
}
return ERROR_OK;
}

@@ -581,7 +581,7 @@ void jlink_tap_ensure_space(int scans, int bits)
{
int available_scans = MAX_PENDING_SCAN_RESULTS - pending_scan_results_length;
int available_bits = JLINK_TAP_BUFFER_SIZE * 8 - tap_length;
if (scans > available_scans || bits > available_bits)
{
jlink_tap_execute();
@@ -592,12 +592,12 @@ void jlink_tap_append_step(int tms, int tdi)
{
last_tms = tms;
int index = tap_length / 8;
if (index < JLINK_TAP_BUFFER_SIZE)
{
int bit_index = tap_length % 8;
u8 bit = 1 << bit_index;
if (tms)
{
tms_buffer[index] |= bit;
@@ -606,7 +606,7 @@ void jlink_tap_append_step(int tms, int tdi)
{
tms_buffer[index] &= ~bit;
}
if (tdi)
{
tdi_buffer[index] |= bit;
@@ -615,7 +615,7 @@ void jlink_tap_append_step(int tms, int tdi)
{
tdi_buffer[index] &= ~bit;
}
tap_length++;
}
else
@@ -628,12 +628,12 @@ void jlink_tap_append_scan(int length, u8 *buffer, scan_command_t *command)
{
pending_scan_result_t *pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length];
int i;
pending_scan_result->first = tap_length;
pending_scan_result->length = length;
pending_scan_result->command = command;
pending_scan_result->buffer = buffer;
for (i = 0; i < length; i++)
{
jlink_tap_append_step((i < length-1 ? 0 : 1), (buffer[i/8] >> (i%8)) & 1);
@@ -650,7 +650,7 @@ int jlink_tap_execute(void)
int tdi_offset;
int i;
int result;
if (tap_length > 0)
{
/* Pad last byte so that tap_length is divisible by 8 */
@@ -660,35 +660,35 @@ int jlink_tap_execute(void)
* analogous to free-running JTAG interfaces. */
jlink_tap_append_step(last_tms, 0);
}
byte_length = tap_length / 8;
usb_out_buffer[0] = EMU_CMD_HW_JTAG3;
usb_out_buffer[1] = 0;
usb_out_buffer[2] = (tap_length >> 0) & 0xff;
usb_out_buffer[3] = (tap_length >> 8) & 0xff;
tms_offset = 4;
for (i = 0; i < byte_length; i++)
{
usb_out_buffer[tms_offset + i] = tms_buffer[i];
}
tdi_offset = tms_offset + byte_length;
for (i = 0; i < byte_length; i++)
{
usb_out_buffer[tdi_offset + i] = tdi_buffer[i];
}
result = jlink_usb_message(jlink_jtag_handle, 4 + 2 * byte_length, byte_length);
if (result == byte_length)
{
for (i = 0; i < byte_length; i++)
{
tdo_buffer[i] = usb_in_buffer[i];
}
for (i = 0; i < pending_scan_results_length; i++)
{
pending_scan_result_t *pending_scan_result = &pending_scan_results_buffer[i];
@@ -696,22 +696,22 @@ int jlink_tap_execute(void)
int length = pending_scan_result->length;
int first = pending_scan_result->first;
scan_command_t *command = pending_scan_result->command;
/* Copy to buffer */
buf_set_buf(tdo_buffer, first, buffer, 0, length);
DEBUG_JTAG_IO("pending scan result, length = %d", length);
#ifdef _DEBUG_USB_COMMS_
jlink_debug_buffer(buffer, byte_length);
#endif
if (jtag_read_buffer(buffer, command) != ERROR_OK)
{
jlink_tap_init();
return ERROR_JTAG_QUEUE_FAILED;
}
if (pending_scan_result->buffer != NULL)
{
free(pending_scan_result->buffer);
@@ -723,10 +723,10 @@ int jlink_tap_execute(void)
LOG_ERROR("jlink_tap_execute, wrong result %d, expected %d", result, byte_length);
return ERROR_JTAG_QUEUE_FAILED;
}
jlink_tap_init();
}
return ERROR_OK;
}

@@ -738,19 +738,19 @@ jlink_jtag_t* jlink_usb_open()
struct usb_bus *busses;
struct usb_bus *bus;
struct usb_device *dev;
jlink_jtag_t *result;
result = (jlink_jtag_t*) malloc(sizeof(jlink_jtag_t));
usb_init();
usb_find_busses();
usb_find_devices();
busses = usb_get_busses();
/* find jlink_jtag device in usb bus */
for (bus = busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
@@ -758,23 +758,23 @@ jlink_jtag_t* jlink_usb_open()
if ((dev->descriptor.idVendor == VID) && (dev->descriptor.idProduct == PID))
{
result->usb_handle = usb_open(dev);
/* usb_set_configuration required under win32 */
usb_set_configuration(result->usb_handle, dev->config[0].bConfigurationValue);
usb_claim_interface(result->usb_handle, 0);
#if 0
/*
/*
* This makes problems under Mac OS X. And is not needed
* under Windows. Hopefully this will not break a linux build
*/
usb_set_altinterface(result->usb_handle, 0);
#endif
#endif
return result;
}
}
}
free(result);
return NULL;
}
@@ -790,7 +790,7 @@ int jlink_usb_message(jlink_jtag_t *jlink_jtag, int out_length, int in_length)
{
int result;
int result2;
result = jlink_usb_write(jlink_jtag, out_length);
if (result == out_length)
{
@@ -811,7 +811,7 @@ int jlink_usb_message(jlink_jtag_t *jlink_jtag, int out_length, int in_length)
else
{
LOG_ERROR("jlink_usb_read_emu_result (requested=0, result=%d)", usb_emu_result_buffer[0]);
return -1;
return -1;
}
}
else
@@ -830,7 +830,7 @@ int jlink_usb_message(jlink_jtag_t *jlink_jtag, int out_length, int in_length)
else
{
LOG_ERROR("jlink_usb_read_emu_result (requested=0, result=%d)", usb_in_buffer[result]);
return -1;
return -1;
}
}
}
@@ -851,18 +851,18 @@ int jlink_usb_message(jlink_jtag_t *jlink_jtag, int out_length, int in_length)
int jlink_usb_write(jlink_jtag_t *jlink_jtag, int out_length)
{
int result;
if (out_length > JLINK_OUT_BUFFER_SIZE)
{
LOG_ERROR("jlink_jtag_write illegal out_length=%d (max=%d)", out_length, JLINK_OUT_BUFFER_SIZE);
return -1;
}
result = usb_bulk_write(jlink_jtag->usb_handle, JLINK_WRITE_ENDPOINT, \
usb_out_buffer, out_length, JLINK_USB_TIMEOUT);
DEBUG_JTAG_IO("jlink_usb_write, out_length = %d, result = %d", out_length, result);
#ifdef _DEBUG_USB_COMMS_
jlink_debug_buffer(usb_out_buffer, out_length);
#endif
@@ -876,7 +876,7 @@ int jlink_usb_read(jlink_jtag_t *jlink_jtag)
usb_in_buffer, JLINK_IN_BUFFER_SIZE, JLINK_USB_TIMEOUT);

DEBUG_JTAG_IO("jlink_usb_read, result = %d", result);
#ifdef _DEBUG_USB_COMMS_
jlink_debug_buffer(usb_in_buffer, result);
#endif
@@ -890,7 +890,7 @@ int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag)
usb_emu_result_buffer, JLINK_EMU_RESULT_BUFFER_SIZE, JLINK_USB_TIMEOUT);

DEBUG_JTAG_IO("jlink_usb_read_result, result = %d", result);
#ifdef _DEBUG_USB_COMMS_
jlink_debug_buffer(usb_emu_result_buffer, result);
#endif
@@ -906,7 +906,7 @@ void jlink_debug_buffer(u8 *buffer, int length)
char s[4];
int i;
int j;
for (i = 0; i < length; i += BYTES_PER_LINE)
{
snprintf(line, 5, "%04x", i);


+ 37
- 37
src/jtag/jtag.c View File

@@ -87,22 +87,22 @@ int tap_move_map[16] = {

tap_transition_t tap_transitions[16] =
{
{TAP_TLR, TAP_RTI}, /* TLR */
{TAP_SIS, TAP_CD}, /* SDS */
{TAP_E1D, TAP_SD}, /* CD */
{TAP_E1D, TAP_SD}, /* SD */
{TAP_UD, TAP_PD}, /* E1D */
{TAP_E2D, TAP_PD}, /* PD */
{TAP_UD, TAP_SD}, /* E2D */
{TAP_SDS, TAP_RTI}, /* UD */
{TAP_SDS, TAP_RTI}, /* RTI */
{TAP_TLR, TAP_CI}, /* SIS */
{TAP_E1I, TAP_SI}, /* CI */
{TAP_E1I, TAP_SI}, /* SI */
{TAP_UI, TAP_PI}, /* E1I */
{TAP_E2I, TAP_PI}, /* PI */
{TAP_UI, TAP_SI}, /* E2I */
{TAP_SDS, TAP_RTI} /* UI */
{TAP_RESET, TAP_IDLE}, /* TLR */
{TAP_IRSELECT, TAP_DRCAPTURE}, /* SDS */
{TAP_DREXIT1, TAP_DRSHIFT}, /* CD */
{TAP_DREXIT1, TAP_DRSHIFT}, /* SD */
{TAP_DRUPDATE, TAP_DRPAUSE}, /* E1D */
{TAP_DREXIT2, TAP_DRPAUSE}, /* PD */
{TAP_DRUPDATE, TAP_DRSHIFT}, /* E2D */
{TAP_DRSELECT, TAP_IDLE}, /* UD */
{TAP_DRSELECT, TAP_IDLE}, /* RTI */
{TAP_RESET, TAP_IRCAPTURE}, /* SIS */
{TAP_IREXIT1, TAP_IRSHIFT}, /* CI */
{TAP_IREXIT1, TAP_IRSHIFT}, /* SI */
{TAP_IRUPDATE, TAP_IRPAUSE}, /* E1I */
{TAP_IREXIT2, TAP_IRPAUSE}, /* PI */
{TAP_IRUPDATE, TAP_IRSHIFT}, /* E2I */
{TAP_DRSELECT, TAP_IDLE} /* UI */
};

char* jtag_event_strings[] =
@@ -115,8 +115,8 @@ char* jtag_event_strings[] =
* inside the drivers, but we don't want to break
* linking the drivers!!!!
*/
enum tap_state end_state = TAP_TLR;
enum tap_state cur_state = TAP_TLR;
enum tap_state end_state = TAP_RESET;
enum tap_state cur_state = TAP_RESET;
int jtag_trst = 0;
int jtag_srst = 0;

@@ -125,8 +125,8 @@ jtag_command_t **last_comand_pointer = &jtag_command_queue;
static jtag_tap_t *jtag_all_taps = NULL;

enum reset_types jtag_reset_config = RESET_NONE;
enum tap_state cmd_queue_end_state = TAP_TLR;
enum tap_state cmd_queue_cur_state = TAP_TLR;
enum tap_state cmd_queue_end_state = TAP_RESET;
enum tap_state cmd_queue_cur_state = TAP_RESET;

int jtag_verify_capture_ir = 1;

@@ -477,7 +477,7 @@ void* cmd_queue_alloc(size_t size)
* alignment.
*
* What I do not/have is a reasonable portable means
* to align by...
* to align by...
*
* The solution here, is based on these suggestions.
* http://gcc.gnu.org/ml/gcc-help/2008-12/msg00041.html
@@ -493,8 +493,8 @@ void* cmd_queue_alloc(size_t size)

// The alignment process.
size = (size + ALIGN_SIZE -1) & (~(ALIGN_SIZE-1));
// Done...
// Done...

if (*p_page)
{
@@ -543,7 +543,7 @@ static void jtag_prelude1(void)
return;
}

if (cmd_queue_end_state == TAP_TLR)
if (cmd_queue_end_state == TAP_RESET)
jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
}

@@ -959,7 +959,7 @@ int MINIDRIVER(interface_jtag_add_plain_dr_scan)(int num_fields, scan_field_t *f

void jtag_add_tlr(void)
{
jtag_prelude(TAP_TLR);
jtag_prelude(TAP_RESET);

int retval;
retval=interface_jtag_add_tlr();
@@ -969,7 +969,7 @@ void jtag_add_tlr(void)

int MINIDRIVER(interface_jtag_add_tlr)()
{
enum tap_state state = TAP_TLR;