X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Fdsp563xx_once.c;h=267f475e51f586f3ee8708cc91ba77ed38dfe585;hb=c9f51acdc31a6277b9a743974fed06d390df221e;hp=df43ed6e6cb71426395965163809abd4cfdc718c;hpb=08bf273def9dcd4bae020f1fc2edecb835f6f32e;p=openocd.git diff --git a/src/target/dsp563xx_once.c b/src/target/dsp563xx_once.c index df43ed6e6c..267f475e51 100644 --- a/src/target/dsp563xx_once.c +++ b/src/target/dsp563xx_once.c @@ -29,6 +29,9 @@ #include "dsp563xx.h" #include "dsp563xx_once.h" +#define JTAG_STATUS_STATIC_MASK 0x03 +#define JTAG_STATUS_STATIC_VALUE 0x01 + #define JTAG_STATUS_NORMAL 0x01 #define JTAG_STATUS_STOPWAIT 0x05 #define JTAG_STATUS_BUSY 0x09 @@ -37,78 +40,47 @@ #define JTAG_INSTR_EXTEST 0x00 #define JTAG_INSTR_SAMPLE_PRELOAD 0x01 #define JTAG_INSTR_IDCODE 0x02 -#define JTAG_INSTR_CLAMP 0x03 #define JTAG_INSTR_HIZ 0x04 +#define JTAG_INSTR_CLAMP 0x05 #define JTAG_INSTR_ENABLE_ONCE 0x06 #define JTAG_INSTR_DEBUG_REQUEST 0x07 #define JTAG_INSTR_BYPASS 0x0F +/** */ static inline int dsp563xx_write_dr(struct jtag_tap *tap, uint8_t * dr_in, uint8_t * dr_out, int dr_len, int rti) { - if (NULL == tap) - { - LOG_ERROR("invalid tap"); - return ERROR_FAIL; - } - jtag_add_plain_dr_scan(dr_len, dr_out, dr_in, TAP_IDLE); return ERROR_OK; } +/** */ static inline int dsp563xx_write_dr_u8(struct jtag_tap *tap, uint8_t * dr_in, uint8_t dr_out, int dr_len, int rti) { - if (dr_len > 8) - { - LOG_ERROR("dr_len overflow, maxium is 8"); - return ERROR_FAIL; - } - return dsp563xx_write_dr(tap, dr_in, &dr_out, dr_len, rti); } +/** */ static inline int dsp563xx_write_dr_u32(struct jtag_tap *tap, uint32_t * dr_in, uint32_t dr_out, int dr_len, int rti) { - if (dr_len > 32) - { - LOG_ERROR("dr_len overflow, maxium is 32"); - return ERROR_FAIL; - } - return dsp563xx_write_dr(tap, (uint8_t *) dr_in, (uint8_t *) & dr_out, dr_len, rti); } /** single word instruction */ -static inline int dsp563xx_once_ir_exec(struct jtag_tap *tap, uint8_t instr, uint8_t rw, uint8_t go, uint8_t ex) +static inline int dsp563xx_once_ir_exec(struct jtag_tap *tap, int flush, uint8_t instr, uint8_t rw, uint8_t go, uint8_t ex) { int err; if ((err = dsp563xx_write_dr_u8(tap, 0, instr | (ex << 5) | (go << 6) | (rw << 7), 8, 0)) != ERROR_OK) return err; - - return jtag_execute_queue(); -} - -/** single word instruction */ -static inline inline int dsp563xx_once_ir_exec_nq(struct jtag_tap *tap, uint8_t instr, uint8_t rw, uint8_t go, uint8_t ex) -{ - return dsp563xx_write_dr_u8(tap, 0, instr | (ex << 5) | (go << 6) | (rw << 7), 8, 0); + if ( flush ) + err = jtag_execute_queue(); + return err; } /* IR and DR functions */ static inline int dsp563xx_write_ir(struct jtag_tap *tap, uint8_t * ir_in, uint8_t * ir_out, int ir_len, int rti) { - if (NULL == tap) - { - LOG_ERROR("invalid tap"); - return ERROR_FAIL; - } - if (ir_len != tap->ir_length) - { - LOG_ERROR("invalid ir_len"); - return ERROR_FAIL; - } - jtag_add_plain_ir_scan(tap->ir_length, ir_out, ir_in, TAP_IDLE); return ERROR_OK; @@ -116,12 +88,6 @@ static inline int dsp563xx_write_ir(struct jtag_tap *tap, uint8_t * ir_in, uint8 static inline int dsp563xx_write_ir_u8(struct jtag_tap *tap, uint8_t * ir_in, uint8_t ir_out, int ir_len, int rti) { - if (ir_len > 8) - { - LOG_ERROR("ir_len overflow, maxium is 8"); - return ERROR_FAIL; - } - return dsp563xx_write_ir(tap, ir_in, &ir_out, ir_len, rti); } @@ -137,19 +103,16 @@ int dsp563xx_once_target_status(struct jtag_tap *tap) uint8_t jtag_status; if ((err = dsp563xx_jtag_sendinstr(tap, &jtag_status, JTAG_INSTR_ENABLE_ONCE)) != ERROR_OK) - return err; + return TARGET_UNKNOWN; if ((err = jtag_execute_queue()) != ERROR_OK) - return err; + return TARGET_UNKNOWN; - if ((jtag_status & 1) != 1) - { + /* verify correct static status pattern */ + if ( (jtag_status & JTAG_STATUS_STATIC_MASK) != JTAG_STATUS_STATIC_VALUE ) return TARGET_UNKNOWN; - } if (jtag_status != JTAG_STATUS_DEBUG) - { return TARGET_RUNNING; - } return TARGET_HALTED; } @@ -222,132 +185,98 @@ int dsp563xx_once_request_debug(struct jtag_tap *tap, int reset_state) } /** once read registers */ -int dsp563xx_once_read_register(struct jtag_tap *tap, struct once_reg *regs, int len) +int dsp563xx_once_read_register(struct jtag_tap *tap, int flush, struct once_reg *regs, int len) { int i; - int err; + int err = ERROR_OK; for (i = 0; i < len; i++) { - if ((err = dsp563xx_once_reg_read_ex_nq(tap, regs[i].addr, regs[i].len, ®s[i].reg)) != ERROR_OK) + if ((err = dsp563xx_once_reg_read_ex(tap, flush, regs[i].addr, regs[i].len, ®s[i].reg)) != ERROR_OK) return err; } - return jtag_execute_queue(); -/* - for(i=0;i