diff options
author | Oleksij Rempel <linux@rempel-privat.de> | 2013-06-26 10:56:23 +0200 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2013-07-17 14:33:30 +0000 |
commit | 6a5848faeb8415a5524ca6fc8c77c9ea89d0165c (patch) | |
tree | 47b943ef18cabce60578c1349cf8101ba1f6078d | |
parent | 3610f2f09b1ff20c9de265848129111ce87aa3b4 (diff) | |
download | riscv-openocd-6a5848faeb8415a5524ca6fc8c77c9ea89d0165c.zip riscv-openocd-6a5848faeb8415a5524ca6fc8c77c9ea89d0165c.tar.gz riscv-openocd-6a5848faeb8415a5524ca6fc8c77c9ea89d0165c.tar.bz2 |
mips32: add new functions mips32_configure_ibs and _dbs
Split function mips32_configure_break_unit
to mips32_configure_ibs and mips32_configure_dbs
to make code more readable.
This will probably make work easyer with differnet EJTAG versions.
Change-Id: I666f949fd7bc3656bdf75e7bcaadb164f15855dd
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1463
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
-rw-r--r-- | src/target/mips32.c | 81 |
1 files changed, 53 insertions, 28 deletions
diff --git a/src/target/mips32.c b/src/target/mips32.c index d649901..16988b5 100644 --- a/src/target/mips32.c +++ b/src/target/mips32.c @@ -469,13 +469,62 @@ int mips32_examine(struct target *target) return ERROR_OK; } +static int mips32_configure_ibs(struct target *target) +{ + struct mips32_common *mips32 = target_to_mips32(target); + int retval, i; + uint32_t bpinfo; + + /* get number of inst breakpoints */ + retval = target_read_u32(target, EJTAG_IBS, &bpinfo); + if (retval != ERROR_OK) + return retval; + + mips32->num_inst_bpoints = (bpinfo >> 24) & 0x0F; + mips32->num_inst_bpoints_avail = mips32->num_inst_bpoints; + mips32->inst_break_list = calloc(mips32->num_inst_bpoints, + sizeof(struct mips32_comparator)); + + for (i = 0; i < mips32->num_inst_bpoints; i++) + mips32->inst_break_list[i].reg_address = + EJTAG_IBA1 + (0x100 * i); + + /* clear IBIS reg */ + retval = target_write_u32(target, EJTAG_IBS, 0); + return retval; +} + +static int mips32_configure_dbs(struct target *target) +{ + struct mips32_common *mips32 = target_to_mips32(target); + int retval, i; + uint32_t bpinfo; + + /* get number of data breakpoints */ + retval = target_read_u32(target, EJTAG_DBS, &bpinfo); + if (retval != ERROR_OK) + return retval; + + mips32->num_data_bpoints = (bpinfo >> 24) & 0x0F; + mips32->num_data_bpoints_avail = mips32->num_data_bpoints; + mips32->data_break_list = calloc(mips32->num_data_bpoints, + sizeof(struct mips32_comparator)); + + for (i = 0; i < mips32->num_data_bpoints; i++) + mips32->data_break_list[i].reg_address = + EJTAG_DBA1 + (0x100 * i); + + /* clear DBIS reg */ + retval = target_write_u32(target, EJTAG_DBS, 0); + return retval; +} + int mips32_configure_break_unit(struct target *target) { /* get pointers to arch-specific information */ struct mips32_common *mips32 = target_to_mips32(target); int retval; - uint32_t dcr, bpinfo; - int i; + uint32_t dcr; if (mips32->bp_scanned) return ERROR_OK; @@ -486,37 +535,13 @@ int mips32_configure_break_unit(struct target *target) return retval; if (dcr & EJTAG_DCR_IB) { - /* get number of inst breakpoints */ - retval = target_read_u32(target, EJTAG_IBS, &bpinfo); - if (retval != ERROR_OK) - return retval; - - mips32->num_inst_bpoints = (bpinfo >> 24) & 0x0F; - mips32->num_inst_bpoints_avail = mips32->num_inst_bpoints; - mips32->inst_break_list = calloc(mips32->num_inst_bpoints, sizeof(struct mips32_comparator)); - for (i = 0; i < mips32->num_inst_bpoints; i++) - mips32->inst_break_list[i].reg_address = EJTAG_IBA1 + (0x100 * i); - - /* clear IBIS reg */ - retval = target_write_u32(target, EJTAG_IBS, 0); + retval = mips32_configure_ibs(target); if (retval != ERROR_OK) return retval; } if (dcr & EJTAG_DCR_DB) { - /* get number of data breakpoints */ - retval = target_read_u32(target, EJTAG_DBS, &bpinfo); - if (retval != ERROR_OK) - return retval; - - mips32->num_data_bpoints = (bpinfo >> 24) & 0x0F; - mips32->num_data_bpoints_avail = mips32->num_data_bpoints; - mips32->data_break_list = calloc(mips32->num_data_bpoints, sizeof(struct mips32_comparator)); - for (i = 0; i < mips32->num_data_bpoints; i++) - mips32->data_break_list[i].reg_address = EJTAG_DBA1 + (0x100 * i); - - /* clear DBIS reg */ - retval = target_write_u32(target, EJTAG_DBS, 0); + retval = mips32_configure_dbs(target); if (retval != ERROR_OK) return retval; } |