* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
return true;
/* optionally ignore the JTAG version field - bits 28-31 of IDCODE */
- uint32_t mask = tap->ignore_version ? ~(0xf << 28) : ~0;
+ uint32_t mask = tap->ignore_version ? ~(0xfU << 28) : ~0U;
uint32_t idcode = tap->idcode & mask;
/* Loop over the expected identification codes and test for a match */
{
jtag_unregister_event_callback(&jtag_reset_callback, tap);
+ struct jtag_tap_event_action *jteap = tap->event_action;
+ while (jteap) {
+ struct jtag_tap_event_action *next = jteap->next;
+ Jim_DecrRefCount(jteap->interp, jteap->body);
+ free(jteap);
+ jteap = next;
+ }
+
free(tap->expected);
free(tap->expected_mask);
free(tap->expected_ids);
return retval;
jtag = jtag_interface;
- /* LEGACY SUPPORT ... adapter drivers must declare what
- * transports they allow. Until they all do so, assume
- * the legacy drivers are JTAG-only
- */
- if (!transports_are_declared()) {
- LOG_ERROR("Adapter driver '%s' did not declare "
- "which transports it allows; assuming "
- "JTAG-only", jtag->name);
- retval = allow_transports(cmd_ctx, jtag_only);
- if (retval != ERROR_OK)
- return retval;
- }
-
if (jtag->speed == NULL) {
LOG_INFO("This adapter doesn't support configurable speed");
return ERROR_OK;
int adapter_quit(void)
{
- if (!jtag || !jtag->quit)
- return ERROR_OK;
+ if (jtag && jtag->quit) {
+ /* close the JTAG interface */
+ int result = jtag->quit();
+ if (ERROR_OK != result)
+ LOG_ERROR("failed: %d", result);
+ }
- /* close the JTAG interface */
- int result = jtag->quit();
- if (ERROR_OK != result)
- LOG_ERROR("failed: %d", result);
+ struct jtag_tap *t = jtag_all_taps();
+ while (t) {
+ struct jtag_tap *n = t->next_tap;
+ jtag_tap_free(t);
+ t = n;
+ }
return ERROR_OK;
}
{
LOG_DEBUG("convert khz to interface specific speed value");
speed_khz = khz;
- if (jtag != NULL) {
- LOG_DEBUG("have interface set up");
- int speed_div1;
- int retval = jtag->khz(jtag_get_speed_khz(), &speed_div1);
- if (ERROR_OK != retval)
- return retval;
- *speed = speed_div1;
+ if (!jtag)
+ return ERROR_OK;
+ LOG_DEBUG("have interface set up");
+ if (!jtag->khz) {
+ LOG_ERROR("Translation from khz to jtag_speed not implemented");
+ return ERROR_FAIL;
}
+ int speed_div1;
+ int retval = jtag->khz(jtag_get_speed_khz(), &speed_div1);
+ if (ERROR_OK != retval)
+ return retval;
+ *speed = speed_div1;
return ERROR_OK;
}
int retval = jtag_get_speed(&jtag_speed_var);
if (retval != ERROR_OK)
return retval;
- return jtag ? jtag->speed_div(jtag_speed_var, khz) : ERROR_OK;
+ if (!jtag)
+ return ERROR_OK;
+ if (!jtag->speed_div) {
+ LOG_ERROR("Translation from jtag_speed to khz not implemented");
+ return ERROR_FAIL;
+ }
+ return jtag->speed_div(jtag_speed_var, khz);
}
void jtag_set_verify(bool enable)
LOG_ERROR("No Valid JTAG Interface Configured.");
exit(-1);
}
- return jtag->power_dropout(dropout);
+ if (jtag->power_dropout)
+ return jtag->power_dropout(dropout);
+
+ *dropout = 0; /* by default we can't detect power dropout */
+ return ERROR_OK;
}
int jtag_srst_asserted(int *srst_asserted)
{
- return jtag->srst_asserted(srst_asserted);
+ if (jtag->srst_asserted)
+ return jtag->srst_asserted(srst_asserted);
+
+ *srst_asserted = 0; /* by default we can't detect srst asserted */
+ return ERROR_OK;
}
enum reset_types jtag_get_reset_config(void)
int jtag_get_trst(void)
{
- return jtag_trst;
+ return jtag_trst == 1;
}
int jtag_get_srst(void)
{
- return jtag_srst;
+ return jtag_srst == 1;
}
void jtag_set_nsrst_delay(unsigned delay)
LOG_ERROR("transport is not selected");
}
-int adapter_config_trace(bool enabled, enum tpio_pin_protocol pin_protocol,
+int adapter_config_trace(bool enabled, enum tpiu_pin_protocol pin_protocol,
uint32_t port_size, unsigned int *trace_freq)
{
if (jtag->config_trace)