2022-06-26 23:24:07 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
|
2006-06-02 10:36:31 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2005 by Dominic Rath *
|
|
|
|
* Dominic.Rath@gmx.de *
|
|
|
|
* *
|
2010-03-18 11:07:41 +00:00
|
|
|
* Copyright (C) 2007-2010 Øyvind Harboe *
|
2008-07-25 06:54:17 +00:00
|
|
|
* oyvind.harboe@zylin.com *
|
2006-06-02 10:36:31 +00:00
|
|
|
***************************************************************************/
|
2012-02-05 12:03:04 +00:00
|
|
|
|
2015-09-21 19:07:46 +00:00
|
|
|
#ifndef OPENOCD_TARGET_ARM_JTAG_H
|
|
|
|
#define OPENOCD_TARGET_ARM_JTAG_H
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2009-12-03 12:14:31 +00:00
|
|
|
#include <jtag/jtag.h>
|
2021-12-02 08:08:33 +00:00
|
|
|
#include <helper/bits.h>
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2012-02-05 12:03:04 +00:00
|
|
|
struct arm_jtag {
|
2009-11-13 11:19:35 +00:00
|
|
|
struct jtag_tap *tap;
|
2009-05-08 08:46:28 +00:00
|
|
|
|
2009-06-18 07:08:52 +00:00
|
|
|
uint32_t scann_size;
|
|
|
|
uint32_t scann_instr;
|
|
|
|
uint32_t cur_scan_chain;
|
2009-05-08 08:46:28 +00:00
|
|
|
|
2009-06-18 07:08:52 +00:00
|
|
|
uint32_t intest_instr;
|
2009-11-13 16:41:00 +00:00
|
|
|
};
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2015-11-13 23:30:28 +00:00
|
|
|
int arm_jtag_set_instr_inner(struct jtag_tap *tap, uint32_t new_instr,
|
2010-03-18 11:07:41 +00:00
|
|
|
void *no_verify_capture,
|
|
|
|
tap_state_t end_state);
|
2012-02-05 12:03:04 +00:00
|
|
|
|
2015-11-13 23:30:28 +00:00
|
|
|
static inline int arm_jtag_set_instr(struct jtag_tap *tap,
|
2010-03-18 11:07:41 +00:00
|
|
|
uint32_t new_instr, void *no_verify_capture, tap_state_t end_state)
|
2009-12-10 14:00:19 +00:00
|
|
|
{
|
|
|
|
/* inline most common code path */
|
2021-12-02 08:08:33 +00:00
|
|
|
if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != (new_instr & (BIT(tap->ir_length) - 1)))
|
2015-11-13 23:30:28 +00:00
|
|
|
return arm_jtag_set_instr_inner(tap, new_instr, no_verify_capture, end_state);
|
2009-12-10 14:00:19 +00:00
|
|
|
|
|
|
|
return ERROR_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-03-18 11:07:41 +00:00
|
|
|
int arm_jtag_scann_inner(struct arm_jtag *jtag_info, uint32_t new_scan_chain, tap_state_t end_state);
|
|
|
|
static inline int arm_jtag_scann(struct arm_jtag *jtag_info, uint32_t new_scan_chain, tap_state_t end_state)
|
2009-12-10 14:00:19 +00:00
|
|
|
{
|
|
|
|
/* inline most common code path */
|
|
|
|
int retval = ERROR_OK;
|
|
|
|
if (jtag_info->cur_scan_chain != new_scan_chain)
|
2010-03-18 11:07:41 +00:00
|
|
|
return arm_jtag_scann_inner(jtag_info, new_scan_chain, end_state);
|
2009-12-10 14:00:19 +00:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2009-11-13 16:41:00 +00:00
|
|
|
int arm_jtag_setup_connection(struct arm_jtag *jtag_info);
|
2020-06-14 21:18:21 +00:00
|
|
|
int arm_jtag_close_connection(struct arm_jtag *jtag_info);
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2009-05-11 06:55:00 +00:00
|
|
|
/* use this as a static so we can inline it in -O3 and refer to it via a pointer */
|
2012-02-05 12:03:04 +00:00
|
|
|
static inline void arm7flip32(jtag_callback_data_t arg)
|
2009-05-11 06:55:00 +00:00
|
|
|
{
|
2012-02-05 12:03:04 +00:00
|
|
|
uint8_t *in = (uint8_t *)arg;
|
|
|
|
*((uint32_t *)arg) = flip_u32(le_to_h_u32(in), 32);
|
2009-05-11 06:55:00 +00:00
|
|
|
}
|
|
|
|
|
2012-02-05 12:03:04 +00:00
|
|
|
static inline void arm_le_to_h_u32(jtag_callback_data_t arg)
|
2009-05-11 06:55:00 +00:00
|
|
|
{
|
2012-02-05 12:03:04 +00:00
|
|
|
uint8_t *in = (uint8_t *)arg;
|
|
|
|
*((uint32_t *)arg) = le_to_h_u32(in);
|
2009-05-11 06:55:00 +00:00
|
|
|
}
|
|
|
|
|
2015-09-21 19:07:46 +00:00
|
|
|
#endif /* OPENOCD_TARGET_ARM_JTAG_H */
|