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>
This commit is contained in:
Oleksij Rempel 2013-06-26 10:56:23 +02:00 committed by Spencer Oliver
parent 3610f2f09b
commit 6a5848faeb
1 changed files with 53 additions and 28 deletions

View File

@ -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;
}