AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(elf.h)
AC_CHECK_HEADERS(strings.h)
+AC_CHECK_HEADERS(stdbool.h)
AC_HEADER_TIME
typedef struct jtag_tap_s jtag_tap_t;
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#else /* HAVE_STDBOOL_H */
+#define __bool_true_false_are_defined 1
+
+#ifndef __cplusplus
+
+#define false 0
+#define true 1
+
+#define bool _Bool
+typedef int _Bool;
+#endif /* __cplusplus */
+
+#endif /* HAVE_STDBOOL_H */
/* DANGER!!!! here be dragons!
*
state_count = 0;
while (num_states)
{
- if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+ if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
{
tms = 0;
}
- else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+ else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
{
tms = 1;
}
for (i = 0; i<=cmd->num_states; i++)
{
- if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[i])
+ if (tap_state_transition(tap_get_state(), false) == cmd->path[i])
bitq_io(0, 0, 0);
- else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[i])
+ else if (tap_state_transition(tap_get_state(), true) == cmd->path[i])
bitq_io(1, 0, 0);
else
{
while (num_states_batch--)
{
- if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+ if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
buf_set_u32(&tms_byte, bit_count++, 1, 0x0);
- else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+ else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
buf_set_u32(&tms_byte, bit_count++, 1, 0x1);
else
{
while (num_states)
{
gw16012_control(0x0); /* single-bit mode */
- if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+ if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
{
gw16012_data(0x0); /* TCK cycle with TMS low */
}
- else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+ else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
{
gw16012_data(0x2); /* TCK cycle with TMS high */
}
for (i = 0; i < num_states; i++)
{
- if (path[i] == tap_state_transition(tap_get_state(), FALSE))
+ if (path[i] == tap_state_transition(tap_get_state(), false))
{
jlink_tap_append_step(0, 0);
}
- else if (path[i] == tap_state_transition(tap_get_state(), TRUE))
+ else if (path[i] == tap_state_transition(tap_get_state(), true))
{
jlink_tap_append_step(1, 0);
}
LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences");
exit(-1);
}
- if ( tap_state_transition(cur_state, 1) != path[i]
- && tap_state_transition(cur_state, 0) != path[i])
+ if ( tap_state_transition(cur_state, true) != path[i]
+ && tap_state_transition(cur_state, false) != path[i])
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(cur_state), tap_state_name(path[i]));
exit(-1);
}
}
+
/*-----<Cable Helper API>---------------------------------------*/
/* these Cable Helper API functions are all documented in the jtag.h header file,
return end_state_follower;
}
+
int tap_move_ndx( tap_state_t astate )
{
/* given a stable state, return the index into the tms_seqs[] array within tap_get_tms_path() */
return ndx;
}
+
int tap_get_tms_path( tap_state_t from, tap_state_t to )
{
/* tap_move[i][j]: tap movement command to go from state i to state j
return tms_seqs[tap_move_ndx(from)][tap_move_ndx(to)];
}
-int tap_is_state_stable(tap_state_t astate)
+
+bool tap_is_state_stable(tap_state_t astate)
{
- int is_stable;
+ bool is_stable;
/* A switch() is used because it is symbol dependent
(not value dependent like an array), and can also check bounds.
case TAP_DRPAUSE:
case TAP_IRSHIFT:
case TAP_IRPAUSE:
- is_stable = 1;
+ is_stable = true;
break;
default:
- is_stable = 0;
+ is_stable = false;
}
return is_stable;
}
-tap_state_t tap_state_transition(tap_state_t cur_state, int tms)
+tap_state_t tap_state_transition(tap_state_t cur_state, bool tms)
{
tap_state_t new_state;
#include "command.h"
+
#if 0
#define _DEBUG_JTAG_IO_
#endif
#define DEBUG_JTAG_IOZ 64
#endif
+
/* 16 Tap States, from page 21 of ASSET InterTech, Inc.'s svf.pdf
*/
enum tap_state {
//extern tap_transition_t tap_transitions[16]; /* describe the TAP state diagram */
+
/*-----<Cable Helper API>-------------------------------------------*/
/* The "Cable Helper API" is what the cable drivers can use to help implement
/**
* Function tap_is_state_stable
- * returns TRUE if the \a astate is stable.
+ * returns true if the \a astate is stable.
*/
-int tap_is_state_stable(tap_state_t astate);
+bool tap_is_state_stable(tap_state_t astate);
/**
* Function tap_state_transition
* @param tms is either zero or non-zero, just like a real TMS line in a jtag interface.
* @return tap_state_t - the next state a TAP would enter.
*/
-tap_state_t tap_state_transition(tap_state_t current_state, int tms);
+tap_state_t tap_state_transition(tap_state_t current_state, bool tms);
/**
* Function tap_state_name
/*-----</Cable Helper API>------------------------------------------*/
+
extern tap_state_t cmd_queue_end_state; /* finish DR scans in dr_end_state */
extern tap_state_t cmd_queue_cur_state; /* current TAP state */
state_count = 0;
while (num_states)
{
- if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+ if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
{
tms = 0;
}
- else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+ else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
{
tms = 1;
}
state_count = 0;
while (num_states)
{
- if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+ if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
{
/* LOG_INFO("1"); */
usbprog_write(0, 0, 0);
usbprog_write(1, 0, 0);
}
- else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+ else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
{
/* LOG_INFO("2"); */
usbprog_write(0, 1, 0);
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] = 0;
}
- if (path[i - start] == tap_state_transition(tap_get_state(), TRUE))
+ if (path[i - start] == tap_state_transition(tap_get_state(), true))
{
vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] |= 1 << (i & 7);
}
- else if (path[i - start] == tap_state_transition(tap_get_state(), FALSE))
+ else if (path[i - start] == tap_state_transition(tap_get_state(), false))
{
// nothing to do
}
while (num_states)
{
- if (tap_state_transition(cur_state, FALSE) == path[state_count])
+ if (tap_state_transition(cur_state, false) == path[state_count])
{
tms = 0;
}
- else if (tap_state_transition(cur_state, TRUE) == path[state_count])
+ else if (tap_state_transition(cur_state, true) == path[state_count])
{
tms = 1;
}
int j = (move >> i) & 1;
if (j)
{
- curstate = tap_state_transition(curstate, TRUE);
+ curstate = tap_state_transition(curstate, true);
}
else
{
- curstate = tap_state_transition(curstate, FALSE);
+ curstate = tap_state_transition(curstate, false);
}
moves[i] = curstate;
}