X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Ftarget%2Fmips_ejtag.c;h=9df8a021f461c66e50bc822c8800e8319035d284;hb=0c1ebf2673ef02c5fef7677cbf09d4ad4fa3c533;hp=e3810639ce81b474e63f200e6a0b4420118e2c7b;hpb=0cd84000daab056dea61eb9d60cca538a3716acd;p=fw%2Fopenocd diff --git a/src/target/mips_ejtag.c b/src/target/mips_ejtag.c index e3810639c..9df8a021f 100644 --- a/src/target/mips_ejtag.c +++ b/src/target/mips_ejtag.c @@ -28,13 +28,12 @@ #include "mips32.h" #include "mips_ejtag.h" -int mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, int new_instr) +void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, int new_instr) { struct jtag_tap *tap; tap = ejtag_info->tap; - if (tap == NULL) - return ERROR_FAIL; + assert(tap != NULL); if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != (uint32_t)new_instr) { @@ -48,8 +47,6 @@ int mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, int new_instr) jtag_add_ir_scan(tap, &field, TAP_IDLE); } - - return ERROR_OK; } int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info, uint32_t *idcode) @@ -64,11 +61,12 @@ int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info, uint32_t *idcode) jtag_add_dr_scan(ejtag_info->tap, 1, &field, TAP_IDLE); - if (jtag_execute_queue() != ERROR_OK) + int retval; + if ((retval = jtag_execute_queue()) != ERROR_OK) { LOG_ERROR("register read failed"); + return retval; } - return ERROR_OK; } @@ -84,11 +82,12 @@ static int mips_ejtag_get_impcode(struct mips_ejtag *ejtag_info, uint32_t *impco jtag_add_dr_scan(ejtag_info->tap, 1, &field, TAP_IDLE); - if (jtag_execute_queue() != ERROR_OK) + int retval; + if ((retval = jtag_execute_queue()) != ERROR_OK) { LOG_ERROR("register read failed"); + return retval; } - return ERROR_OK; } @@ -96,9 +95,8 @@ int mips_ejtag_drscan_32(struct mips_ejtag *ejtag_info, uint32_t *data) { struct jtag_tap *tap; tap = ejtag_info->tap; + assert(tap != NULL); - if (tap == NULL) - return ERROR_FAIL; struct scan_field field; uint8_t t[4], r[4]; int retval; @@ -127,9 +125,8 @@ int mips_ejtag_drscan_8(struct mips_ejtag *ejtag_info, uint32_t *data) { struct jtag_tap *tap; tap = ejtag_info->tap; + assert(tap != NULL); - if (tap == NULL) - return ERROR_FAIL; struct scan_field field; uint8_t t[4] = {0, 0, 0, 0}, r[4]; int retval; @@ -165,10 +162,8 @@ static int mips_ejtag_step_enable(struct mips_ejtag *ejtag_info) MIPS32_MFC0(1,31,0), /* move COP0 DeSave to $1 */ }; - mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ - 0, NULL, 0, NULL, 1); - - return ERROR_OK; + return mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, + 0, NULL, 0, NULL, 1); } static int mips_ejtag_step_disable(struct mips_ejtag *ejtag_info) @@ -190,10 +185,8 @@ static int mips_ejtag_step_disable(struct mips_ejtag *ejtag_info) MIPS32_MFC0(15,31,0), /* move COP0 DeSave to $15 */ }; - mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ + return mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, 0, NULL, 0, NULL, 1); - - return ERROR_OK; } int mips_ejtag_config_step(struct mips_ejtag *ejtag_info, int enable_step) @@ -217,7 +210,10 @@ int mips_ejtag_enter_debug(struct mips_ejtag *ejtag_info) mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl); LOG_DEBUG("ejtag_ctrl: 0x%8.8" PRIx32 "", ejtag_ctrl); if ((ejtag_ctrl & EJTAG_CTRL_BRKST) == 0) - LOG_DEBUG("Failed to enter Debug Mode!"); + { + LOG_ERROR("Failed to enter Debug Mode!"); + return ERROR_FAIL; + } return ERROR_OK; } @@ -228,9 +224,7 @@ int mips_ejtag_exit_debug(struct mips_ejtag *ejtag_info) inst = MIPS32_DRET; /* execute our dret instruction */ - mips32_pracc_exec(ejtag_info, 1, &inst, 0, NULL, 0, NULL, 0); - - return ERROR_OK; + return mips32_pracc_exec(ejtag_info, 1, &inst, 0, NULL, 0, NULL, 0); } int mips_ejtag_read_debug(struct mips_ejtag *ejtag_info, uint32_t* debug_reg) @@ -252,17 +246,18 @@ int mips_ejtag_read_debug(struct mips_ejtag *ejtag_info, uint32_t* debug_reg) MIPS32_MFC0(15,31,0), /* move COP0 DeSave to $15 */ }; - mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \ + return mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, 0, NULL, 1, debug_reg, 1); - - return ERROR_OK; } int mips_ejtag_init(struct mips_ejtag *ejtag_info) { uint32_t ejtag_version; + int retval; - mips_ejtag_get_impcode(ejtag_info, &ejtag_info->impcode); + retval = mips_ejtag_get_impcode(ejtag_info, &ejtag_info->impcode); + if (retval != ERROR_OK) + return retval; LOG_DEBUG("impcode: 0x%8.8" PRIx32 "", ejtag_info->impcode); /* get ejtag version */ @@ -309,9 +304,7 @@ int mips_ejtag_fastdata_scan(struct mips_ejtag *ejtag_info, int write_t, uint32_ { struct jtag_tap *tap; tap = ejtag_info->tap; - - if (tap == NULL) - return ERROR_FAIL; + assert(tap != NULL); struct scan_field fields[2]; uint8_t spracc = 0;