aboutsummaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
authorFranck Jullien <franck.jullien@gmail.com>2014-06-09 21:31:47 +0200
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>2014-06-22 08:38:04 +0000
commitfd9f27bfac1dd9a661913c31774edf4f8cd0798c (patch)
tree4d38113fd1f623029b5a291ac14256cfe9da8ade /src/target
parent667bf9c80fae84c075a422d71140d257b7a23f5a (diff)
downloadriscv-openocd-fd9f27bfac1dd9a661913c31774edf4f8cd0798c.zip
riscv-openocd-fd9f27bfac1dd9a661913c31774edf4f8cd0798c.tar.gz
riscv-openocd-fd9f27bfac1dd9a661913c31774edf4f8cd0798c.tar.bz2
openrisc: restore current JTAG module while polling the CPU
Change-Id: I93827afaa164d23a93bdddbfa864624b18473f45 Signed-off-by: Franck Jullien <franck.jullien@gmail.com> Reviewed-on: http://openocd.zylin.com/2163 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/target')
-rw-r--r--src/target/openrisc/or1k_du_adv.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/target/openrisc/or1k_du_adv.c b/src/target/openrisc/or1k_du_adv.c
index f497a86..8a5562f 100644
--- a/src/target/openrisc/or1k_du_adv.c
+++ b/src/target/openrisc/or1k_du_adv.c
@@ -50,6 +50,7 @@
#define DBG_MODULE_SELECT_REG_SIZE 2
#define DBG_MAX_MODULES 4
+#define DC_NONE -1
#define DC_WISHBONE 0
#define DC_CPU0 1
#define DC_CPU1 2
@@ -173,7 +174,7 @@ static int or1k_adv_jtag_init(struct or1k_jtag *jtag_info)
jtag_info->or1k_jtag_inited = 1;
/* TAP reset - not sure what state debug module chain is in now */
- jtag_info->or1k_jtag_module_selected = -1;
+ jtag_info->or1k_jtag_module_selected = DC_NONE;
jtag_info->current_reg_idx = malloc(DBG_MAX_MODULES * sizeof(uint8_t));
memset(jtag_info->current_reg_idx, 0, DBG_MAX_MODULES * sizeof(uint8_t));
@@ -781,6 +782,8 @@ static int or1k_adv_is_cpu_running(struct or1k_jtag *jtag_info, int *running)
return retval;
}
+ int current = jtag_info->or1k_jtag_module_selected;
+
retval = adbg_select_module(jtag_info, DC_CPU0);
if (retval != ERROR_OK)
return retval;
@@ -795,6 +798,12 @@ static int or1k_adv_is_cpu_running(struct or1k_jtag *jtag_info, int *running)
else
*running = 1;
+ if (current != DC_NONE) {
+ retval = adbg_select_module(jtag_info, current);
+ if (retval != ERROR_OK)
+ return retval;
+ }
+
return ERROR_OK;
}