mips32, use scan32 function for reading impcode/idcode.
There is no need to implement scan code in functions mips_ejtag_get_idcode/impcode(), use mips_ejtag_drscan_32(). Impcode/idcode saved in ejtag.info. Reorder the code in the callers of this functions. Change-Id: Ia829c783a0b24c6a65cade736113fa6f67b0a170 Signed-off-by: Salvador Arroyo <salvador@telecable.es> Reviewed-on: http://openocd.zylin.com/4003 Tested-by: jenkins Reviewed-by: Peter Mamonov <pmamonov@gmail.com> Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>gitignore-build
parent
b702b16dc2
commit
f22b89d9fb
|
@ -48,54 +48,20 @@ void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, uint32_t new_instr)
|
|||
}
|
||||
}
|
||||
|
||||
int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info, uint32_t *idcode)
|
||||
int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info)
|
||||
{
|
||||
struct scan_field field;
|
||||
uint8_t r[4];
|
||||
|
||||
mips_ejtag_set_instr(ejtag_info, EJTAG_INST_IDCODE);
|
||||
|
||||
field.num_bits = 32;
|
||||
field.out_value = NULL;
|
||||
field.in_value = r;
|
||||
|
||||
jtag_add_dr_scan(ejtag_info->tap, 1, &field, TAP_IDLE);
|
||||
|
||||
int retval;
|
||||
retval = jtag_execute_queue();
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_ERROR("register read failed");
|
||||
return retval;
|
||||
}
|
||||
|
||||
*idcode = buf_get_u32(field.in_value, 0, 32);
|
||||
|
||||
return ERROR_OK;
|
||||
ejtag_info->idcode = 0;
|
||||
return mips_ejtag_drscan_32(ejtag_info, &ejtag_info->idcode);
|
||||
}
|
||||
|
||||
static int mips_ejtag_get_impcode(struct mips_ejtag *ejtag_info, uint32_t *impcode)
|
||||
int mips_ejtag_get_impcode(struct mips_ejtag *ejtag_info)
|
||||
{
|
||||
struct scan_field field;
|
||||
uint8_t r[4];
|
||||
|
||||
mips_ejtag_set_instr(ejtag_info, EJTAG_INST_IMPCODE);
|
||||
|
||||
field.num_bits = 32;
|
||||
field.out_value = NULL;
|
||||
field.in_value = r;
|
||||
|
||||
jtag_add_dr_scan(ejtag_info->tap, 1, &field, TAP_IDLE);
|
||||
|
||||
int retval;
|
||||
retval = jtag_execute_queue();
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_ERROR("register read failed");
|
||||
return retval;
|
||||
}
|
||||
|
||||
*impcode = buf_get_u32(field.in_value, 0, 32);
|
||||
|
||||
return ERROR_OK;
|
||||
ejtag_info->impcode = 0;
|
||||
return mips_ejtag_drscan_32(ejtag_info, &ejtag_info->impcode);
|
||||
}
|
||||
|
||||
void mips_ejtag_add_scan_96(struct mips_ejtag *ejtag_info, uint32_t ctrl, uint32_t data, uint8_t *in_scan_buf)
|
||||
|
@ -368,12 +334,11 @@ static void ejtag_main_print_imp(struct mips_ejtag *ejtag_info)
|
|||
|
||||
int mips_ejtag_init(struct mips_ejtag *ejtag_info)
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = mips_ejtag_get_impcode(ejtag_info, &ejtag_info->impcode);
|
||||
if (retval != ERROR_OK)
|
||||
int retval = mips_ejtag_get_impcode(ejtag_info);
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_ERROR("impcode read failed");
|
||||
return retval;
|
||||
LOG_DEBUG("impcode: 0x%8.8" PRIx32 "", ejtag_info->impcode);
|
||||
}
|
||||
|
||||
/* get ejtag version */
|
||||
ejtag_info->ejtag_version = ((ejtag_info->impcode >> 29) & 0x07);
|
||||
|
|
|
@ -219,7 +219,7 @@ struct mips_ejtag {
|
|||
void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, uint32_t new_instr);
|
||||
int mips_ejtag_enter_debug(struct mips_ejtag *ejtag_info);
|
||||
int mips_ejtag_exit_debug(struct mips_ejtag *ejtag_info);
|
||||
int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info, uint32_t *idcode);
|
||||
int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info);
|
||||
void mips_ejtag_add_scan_96(struct mips_ejtag *ejtag_info,
|
||||
uint32_t ctrl, uint32_t data, uint8_t *in_scan_buf);
|
||||
void mips_ejtag_drscan_32_out(struct mips_ejtag *ejtag_info, uint32_t data);
|
||||
|
|
|
@ -1174,36 +1174,30 @@ static int mips_m4k_target_create(struct target *target, Jim_Interp *interp)
|
|||
|
||||
static int mips_m4k_examine(struct target *target)
|
||||
{
|
||||
int retval;
|
||||
struct mips_m4k_common *mips_m4k = target_to_m4k(target);
|
||||
struct mips_ejtag *ejtag_info = &mips_m4k->mips32.ejtag_info;
|
||||
uint32_t idcode = 0;
|
||||
|
||||
if (!target_was_examined(target)) {
|
||||
retval = mips_ejtag_get_idcode(ejtag_info, &idcode);
|
||||
if (retval != ERROR_OK)
|
||||
int retval = mips_ejtag_get_idcode(ejtag_info);
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_ERROR("idcode read failed");
|
||||
return retval;
|
||||
ejtag_info->idcode = idcode;
|
||||
|
||||
if (((idcode >> 1) & 0x7FF) == 0x29) {
|
||||
}
|
||||
if (((ejtag_info->idcode >> 1) & 0x7FF) == 0x29) {
|
||||
/* we are using a pic32mx so select ejtag port
|
||||
* as it is not selected by default */
|
||||
mips_ejtag_set_instr(ejtag_info, MTAP_SW_ETAP);
|
||||
LOG_DEBUG("PIC32MX Detected - using EJTAG Interface");
|
||||
LOG_DEBUG("PIC32 Detected - using EJTAG Interface");
|
||||
mips_m4k->is_pic32mx = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* init rest of ejtag interface */
|
||||
retval = mips_ejtag_init(ejtag_info);
|
||||
int retval = mips_ejtag_init(ejtag_info);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
retval = mips32_examine(target);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
return ERROR_OK;
|
||||
return mips32_examine(target);
|
||||
}
|
||||
|
||||
static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t address,
|
||||
|
|
Loading…
Reference in New Issue