Encapsulate jtag_reset_config using accessors:

- Update handle_reset_config_command in tcl.c to use new helpers.
- Replace direct accesses in JTAG interface and target drivers.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2161 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
zwelch 2009-06-09 08:40:31 +00:00
parent 2a8e37173a
commit 6dc2c2ce97
13 changed files with 37 additions and 10 deletions

View File

@ -500,6 +500,7 @@ static int amt_jtagaccel_init(void)
amt_jtagaccel_speed(jtag_get_speed());
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
aw_control_rst &= ~0x8;
else

View File

@ -258,7 +258,7 @@ int bitbang_execute_queue(void)
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
#endif
if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_reset_config & RESET_SRST_PULLS_TRST)))
if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
{
tap_set_state(TAP_RESET);
}

View File

@ -298,7 +298,7 @@ int bitq_execute_queue(void)
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
#endif
if ( (cmd->cmd.reset->trst == 1) || ( cmd->cmd.reset->srst && (jtag_reset_config & RESET_SRST_PULLS_TRST) ) )
if ( (cmd->cmd.reset->trst == 1) || ( cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST) ) )
{
tap_set_state(TAP_RESET);
}

View File

@ -1262,6 +1262,15 @@ int jtag_add_statemove(tap_state_t goal_state)
return ERROR_OK;
}
enum reset_types jtag_get_reset_config(void)
{
return jtag_reset_config;
}
void jtag_set_reset_config(enum reset_types type)
{
jtag_reset_config = type;
}
int jtag_get_trst(void)
{
return jtag_trst;

View File

@ -123,7 +123,7 @@ static void dummy_reset(int trst, int srst)
{
dummy_clock = 0;
if (trst || (srst && (jtag_reset_config & RESET_SRST_PULLS_TRST)))
if (trst || (srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
dummy_state = TAP_RESET;
LOG_DEBUG("reset to: %s", tap_state_name(dummy_state) );

View File

@ -1193,6 +1193,7 @@ static int ft2232_predict_scan_in(int scan_size, enum scan_type type)
static void usbjtag_reset(int trst, int srst)
{
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (trst == 1)
{
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
@ -1232,6 +1233,7 @@ static void usbjtag_reset(int trst, int srst)
static void jtagkey_reset(int trst, int srst)
{
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (trst == 1)
{
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
@ -1273,6 +1275,7 @@ static void jtagkey_reset(int trst, int srst)
static void olimex_jtag_reset(int trst, int srst)
{
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (trst == 1)
{
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
@ -2155,6 +2158,7 @@ static int usbjtag_init(void)
return ERROR_JTAG_INIT_FAILED;
}
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
{
low_direction &= ~nTRSTnOE; /* nTRST input */
@ -2229,6 +2233,7 @@ static int axm0432_jtag_init(void)
high_output = 0x0;
high_direction = 0x0c;
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
{
LOG_ERROR("can't set nTRSTOE to push-pull on the Dicarlo jtag");
@ -2307,6 +2312,7 @@ static int jtagkey_init(void)
high_output = 0x0;
high_direction = 0x0f;
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
{
high_output |= nTRSTnOE;
@ -2373,6 +2379,7 @@ static int olimex_jtag_init(void)
high_output = 0x0;
high_direction = 0x0f;
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
{
high_output |= nTRSTnOE;
@ -2944,6 +2951,7 @@ static int icebear_jtag_init(void) {
nTRST = 0x10;
nSRST = 0x20;
enum reset_types jtag_reset_config = jtag_get_reset_config();
if ((jtag_reset_config & RESET_TRST_OPEN_DRAIN) != 0) {
low_direction &= ~nTRST; /* nTRST high impedance */
}
@ -2991,6 +2999,7 @@ static void icebear_jtag_reset(int trst, int srst) {
low_output &= ~nTRST;
}
else if (trst == 0) {
enum reset_types jtag_reset_config = jtag_get_reset_config();
if ((jtag_reset_config & RESET_TRST_OPEN_DRAIN) != 0)
low_direction &= ~nTRST;
else

View File

@ -277,7 +277,8 @@ enum reset_types {
RESET_SRST_PUSH_PULL = 0x20,
};
extern enum reset_types jtag_reset_config;
enum reset_types jtag_get_reset_config(void);
void jtag_set_reset_config(enum reset_types type);
/**
* Initialize interface upon startup. Return a successful no-op upon

View File

@ -1419,7 +1419,7 @@ int rlink_execute_queue(void)
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
#endif
if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_reset_config & RESET_SRST_PULLS_TRST)))
if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
{
tap_set_state(TAP_RESET);
}

View File

@ -921,8 +921,10 @@ next:
}
/* clear previous values of those bits, save new values */
jtag_reset_config &= ~mask;
jtag_reset_config |= new_cfg;
enum reset_types old_cfg = jtag_get_reset_config();
old_cfg &= ~mask;
new_cfg |= old_cfg;
jtag_set_reset_config(new_cfg);
return ERROR_OK;
}

View File

@ -164,7 +164,7 @@ void zy1000_reset(int trst, int srst)
ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000002);
}
if (trst||(srst&&(jtag_reset_config & RESET_SRST_PULLS_TRST)))
if (trst||(srst&&(jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
{
waitIdle();
/* we're now in the RESET state until trst is deasserted */

View File

@ -905,6 +905,7 @@ int arm7_9_poll(target_t *target)
{
if (target->reset_halt)
{
enum reset_types jtag_reset_config = jtag_get_reset_config();
if ((jtag_reset_config & RESET_SRST_PULLS_TRST)==0)
{
check_pc = 1;
@ -975,6 +976,7 @@ int arm7_9_assert_reset(target_t *target)
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state,target->state)->name);
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (!(jtag_reset_config & RESET_HAS_SRST))
{
LOG_ERROR("Can't assert SRST");
@ -1047,6 +1049,7 @@ int arm7_9_deassert_reset(target_t *target)
/* deassert reset lines */
jtag_add_reset(0, 0);
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (target->reset_halt&&(jtag_reset_config & RESET_SRST_PULLS_TRST)!=0)
{
LOG_WARNING("srst pulls trst - can not reset into halted mode. Issuing halt after reset.");

View File

@ -544,7 +544,7 @@ int cortex_m3_halt(target_t *target)
if (target->state == TARGET_RESET)
{
if ((jtag_reset_config & RESET_SRST_PULLS_TRST) && jtag_get_srst())
if ((jtag_get_reset_config() & RESET_SRST_PULLS_TRST) && jtag_get_srst())
{
LOG_ERROR("can't request a halt while in reset if nSRST pulls nTRST");
return ERROR_TARGET_FAILURE;
@ -753,6 +753,7 @@ int cortex_m3_assert_reset(target_t *target)
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name );
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (!(jtag_reset_config & RESET_HAS_SRST))
{
LOG_ERROR("Can't assert SRST");

View File

@ -235,7 +235,7 @@ int mips_m4k_halt(struct target_s *target)
if (target->state == TARGET_RESET)
{
if ((jtag_reset_config & RESET_SRST_PULLS_TRST) && jtag_get_srst())
if ((jtag_get_reset_config() & RESET_SRST_PULLS_TRST) && jtag_get_srst())
{
LOG_ERROR("can't request a halt while in reset if nSRST pulls nTRST");
return ERROR_TARGET_FAILURE;
@ -267,6 +267,7 @@ int mips_m4k_assert_reset(target_t *target)
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (!(jtag_reset_config & RESET_HAS_SRST))
{
LOG_ERROR("Can't assert SRST");