more changes to dsp563xx code
Hello, this patch adds the missing cpu registers and the correct read/write register functions and fixed most of the halt/step/resume issues. The complete missing error propagation was added. + fix tab/spaces Regards, Mathias
This commit is contained in:
parent
b0bdc4e2f2
commit
75cdbff5aa
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Mathias Kuester *
|
||||
* Copyright (C) 2009-2011 by Mathias Kuester *
|
||||
* mkdorg@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
|
@ -21,8 +21,10 @@
|
|||
#define DSP563XX_H
|
||||
|
||||
#include <jtag/jtag.h>
|
||||
#include <target/dsp563xx_once.h>
|
||||
|
||||
#define DSP563XX_NUMCOREREGS 44
|
||||
#define DSP563XX_NUMCOREREGS 54
|
||||
#define DSP563XX_NUMONCEREGS 25
|
||||
|
||||
struct mcu_jtag
|
||||
{
|
||||
|
@ -42,6 +44,7 @@ struct dsp563xx_common
|
|||
struct mcu_jtag jtag_info;
|
||||
struct reg_cache *core_cache;
|
||||
uint32_t core_regs[DSP563XX_NUMCOREREGS];
|
||||
struct once_reg once_regs[DSP563XX_NUMONCEREGS];
|
||||
|
||||
struct dsp563xx_pipeline_context pipeline_context;
|
||||
|
||||
|
@ -55,8 +58,8 @@ struct dsp563xx_core_reg
|
|||
uint32_t num;
|
||||
const char *name;
|
||||
uint32_t size;
|
||||
uint32_t r_cmd;
|
||||
uint32_t w_cmd;
|
||||
uint8_t eame;
|
||||
uint32_t instr_mask;
|
||||
struct target *target;
|
||||
struct dsp563xx_common *dsp563xx_common;
|
||||
};
|
||||
|
@ -66,11 +69,4 @@ static inline struct dsp563xx_common *target_to_dsp563xx(struct target *target)
|
|||
return target->arch_info;
|
||||
}
|
||||
|
||||
int dsp563xx_write_dr_u8(struct jtag_tap *tap, uint8_t * ir_in, uint8_t ir_out,
|
||||
int dr_len, int rti);
|
||||
int dsp563xx_write_dr_u32(struct jtag_tap *tap, uint32_t * ir_in, uint32_t ir_out,
|
||||
int dr_len, int rti);
|
||||
|
||||
int dsp563xx_execute_queue(void);
|
||||
|
||||
#endif /* DSP563XX_H */
|
||||
|
|
|
@ -29,74 +29,295 @@
|
|||
#include "dsp563xx.h"
|
||||
#include "dsp563xx_once.h"
|
||||
|
||||
/** single word instruction */
|
||||
static int dsp563xx_once_ir_exec(struct jtag_tap *tap, uint8_t instr, uint8_t rw,
|
||||
uint8_t go, uint8_t ex)
|
||||
#define JTAG_STATUS_NORMAL 0x01
|
||||
#define JTAG_STATUS_STOPWAIT 0x05
|
||||
#define JTAG_STATUS_BUSY 0x09
|
||||
#define JTAG_STATUS_DEBUG 0x0d
|
||||
|
||||
#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_ENABLE_ONCE 0x06
|
||||
#define JTAG_INSTR_DEBUG_REQUEST 0x07
|
||||
#define JTAG_INSTR_BYPASS 0x0F
|
||||
|
||||
static int dsp563xx_write_dr(struct jtag_tap *tap, uint8_t * dr_in, uint8_t * dr_out, int dr_len, int rti)
|
||||
{
|
||||
dsp563xx_write_dr_u8(tap, 0,
|
||||
instr | (ex << 5) | (go << 6) | (rw << 7), 8, 0);
|
||||
dsp563xx_execute_queue();
|
||||
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;
|
||||
}
|
||||
|
||||
/** single word instruction */
|
||||
static int dsp563xx_once_ir_exec_nq(struct jtag_tap *tap, uint8_t instr, uint8_t rw,
|
||||
uint8_t go, uint8_t ex)
|
||||
static int dsp563xx_write_dr_u8(struct jtag_tap *tap, uint8_t * dr_in, uint8_t dr_out, int dr_len, int rti)
|
||||
{
|
||||
dsp563xx_write_dr_u8(tap, 0,
|
||||
instr | (ex << 5) | (go << 6) | (rw << 7), 8, 0);
|
||||
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 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 int dsp563xx_once_ir_exec(struct jtag_tap *tap, 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 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);
|
||||
}
|
||||
|
||||
/* IR and DR functions */
|
||||
static 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;
|
||||
}
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
static int dsp563xx_jtag_sendinstr(struct jtag_tap *tap, uint8_t * ir_in, uint8_t ir_out)
|
||||
{
|
||||
return dsp563xx_write_ir_u8(tap, ir_in, ir_out, tap->ir_length, 1);
|
||||
}
|
||||
|
||||
/** */
|
||||
int dsp563xx_once_target_status(struct jtag_tap *tap)
|
||||
{
|
||||
int err;
|
||||
uint8_t jtag_status;
|
||||
|
||||
if ((err = dsp563xx_jtag_sendinstr(tap, &jtag_status, JTAG_INSTR_ENABLE_ONCE)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = jtag_execute_queue()) != ERROR_OK)
|
||||
return err;
|
||||
|
||||
if ((jtag_status & 1) != 1)
|
||||
{
|
||||
return TARGET_UNKNOWN;
|
||||
}
|
||||
|
||||
if (jtag_status != JTAG_STATUS_DEBUG)
|
||||
{
|
||||
return TARGET_RUNNING;
|
||||
}
|
||||
|
||||
return TARGET_HALTED;
|
||||
}
|
||||
|
||||
/** */
|
||||
int dsp563xx_once_request_debug(struct jtag_tap *tap, int reset_state)
|
||||
{
|
||||
int err;
|
||||
uint8_t ir_in = 0, pattern = 0;
|
||||
uint32_t retry = 0;
|
||||
|
||||
/* in reset state we only get a ACK
|
||||
* from the interface */
|
||||
if (reset_state)
|
||||
{
|
||||
pattern = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pattern = JTAG_STATUS_DEBUG;
|
||||
}
|
||||
|
||||
/* wait until we get the ack */
|
||||
while (ir_in != pattern)
|
||||
{
|
||||
if ((err = dsp563xx_jtag_sendinstr(tap, &ir_in, JTAG_INSTR_DEBUG_REQUEST)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = jtag_execute_queue()) != ERROR_OK)
|
||||
return err;
|
||||
|
||||
LOG_DEBUG("debug request: %02X", ir_in);
|
||||
|
||||
if (retry++ == 100)
|
||||
{
|
||||
return ERROR_TARGET_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* we cant enable the once in reset state */
|
||||
if (pattern == 1)
|
||||
{
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
/* try to enable once */
|
||||
retry = 0;
|
||||
ir_in = 0;
|
||||
while (ir_in != pattern)
|
||||
{
|
||||
if ((err = dsp563xx_jtag_sendinstr(tap, &ir_in, JTAG_INSTR_ENABLE_ONCE)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = jtag_execute_queue()) != ERROR_OK)
|
||||
return err;
|
||||
|
||||
LOG_DEBUG("enable once: %02X", ir_in);
|
||||
|
||||
if (retry++ == 100)
|
||||
{
|
||||
LOG_DEBUG("error");
|
||||
return ERROR_TARGET_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (ir_in != JTAG_STATUS_DEBUG)
|
||||
{
|
||||
return ERROR_TARGET_FAILURE;
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
/** once read registers */
|
||||
int dsp563xx_once_read_register(struct jtag_tap *tap, struct once_reg *regs, int len)
|
||||
{
|
||||
int i;
|
||||
int err;
|
||||
|
||||
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)
|
||||
return err;
|
||||
}
|
||||
|
||||
return jtag_execute_queue();
|
||||
/*
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
printf("%08X\n",regs[i].reg);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/** once read register */
|
||||
int dsp563xx_once_reg_read_ex_nq(struct jtag_tap *tap, uint8_t reg, uint8_t len, uint32_t * data)
|
||||
{
|
||||
int err;
|
||||
|
||||
if ((err = dsp563xx_once_ir_exec(tap, reg, 1, 0, 0)) != ERROR_OK)
|
||||
return err;
|
||||
return dsp563xx_write_dr_u32(tap, data, 0x00, len, 0);
|
||||
}
|
||||
|
||||
/** once read register */
|
||||
int dsp563xx_once_reg_read_ex(struct jtag_tap *tap, uint8_t reg, uint8_t len, uint32_t * data)
|
||||
{
|
||||
int err;
|
||||
|
||||
if ((err = dsp563xx_once_ir_exec(tap, reg, 1, 0, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = dsp563xx_write_dr_u32(tap, data, 0x00, len, 0)) != ERROR_OK)
|
||||
return err;
|
||||
return jtag_execute_queue();
|
||||
}
|
||||
|
||||
/** once read register */
|
||||
int dsp563xx_once_reg_read(struct jtag_tap *tap, uint8_t reg, uint32_t * data)
|
||||
{
|
||||
uint32_t dr_in;
|
||||
int err;
|
||||
|
||||
dr_in = 0;
|
||||
|
||||
dsp563xx_once_ir_exec(tap, reg, 1, 0, 0);
|
||||
dsp563xx_write_dr_u32(tap, &dr_in, 0x00, 24, 0);
|
||||
dsp563xx_execute_queue();
|
||||
|
||||
*data = dr_in;
|
||||
|
||||
return ERROR_OK;
|
||||
if ((err = dsp563xx_once_ir_exec(tap, reg, 1, 0, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = dsp563xx_write_dr_u32(tap, data, 0x00, 24, 0)) != ERROR_OK)
|
||||
return err;
|
||||
return jtag_execute_queue();
|
||||
}
|
||||
|
||||
/** once write register */
|
||||
int dsp563xx_once_reg_write(struct jtag_tap *tap, uint8_t reg, uint32_t data)
|
||||
{
|
||||
dsp563xx_once_ir_exec(tap, reg, 0, 0, 0);
|
||||
dsp563xx_write_dr_u32(tap, 0x00, data, 24, 0);
|
||||
dsp563xx_execute_queue();
|
||||
int err;
|
||||
|
||||
return ERROR_OK;
|
||||
if ((err = dsp563xx_once_ir_exec(tap, reg, 0, 0, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = dsp563xx_write_dr_u32(tap, 0x00, data, 24, 0)) != ERROR_OK)
|
||||
return err;
|
||||
return jtag_execute_queue();
|
||||
}
|
||||
|
||||
/** single word instruction */
|
||||
int dsp563xx_once_execute_sw_ir(struct jtag_tap *tap, uint32_t opcode)
|
||||
{
|
||||
dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
|
||||
dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
|
||||
dsp563xx_execute_queue();
|
||||
int err;
|
||||
|
||||
return ERROR_OK;
|
||||
if ((err = dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0)) != ERROR_OK)
|
||||
return err;
|
||||
return jtag_execute_queue();
|
||||
}
|
||||
|
||||
/** double word instruction */
|
||||
int dsp563xx_once_execute_dw_ir(struct jtag_tap *tap, uint32_t opcode,
|
||||
uint32_t operand)
|
||||
int dsp563xx_once_execute_dw_ir(struct jtag_tap *tap, uint32_t opcode, uint32_t operand)
|
||||
{
|
||||
dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 0, 0);
|
||||
dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
|
||||
dsp563xx_execute_queue();
|
||||
int err;
|
||||
|
||||
dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
|
||||
dsp563xx_write_dr_u32(tap, 0, operand, 24, 0);
|
||||
dsp563xx_execute_queue();
|
||||
if ((err = dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 0, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = jtag_execute_queue()) != ERROR_OK)
|
||||
return err;
|
||||
|
||||
if ((err = dsp563xx_once_ir_exec(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = dsp563xx_write_dr_u32(tap, 0, operand, 24, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = jtag_execute_queue()) != ERROR_OK)
|
||||
return err;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
@ -104,21 +325,29 @@ int dsp563xx_once_execute_dw_ir(struct jtag_tap *tap, uint32_t opcode,
|
|||
/** single word instruction */
|
||||
int dsp563xx_once_execute_sw_ir_nq(struct jtag_tap *tap, uint32_t opcode)
|
||||
{
|
||||
dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
|
||||
dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
|
||||
int err;
|
||||
|
||||
if ((err = dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0)) != ERROR_OK)
|
||||
return err;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
/** double word instruction */
|
||||
int dsp563xx_once_execute_dw_ir_nq(struct jtag_tap *tap, uint32_t opcode,
|
||||
uint32_t operand)
|
||||
int dsp563xx_once_execute_dw_ir_nq(struct jtag_tap *tap, uint32_t opcode, uint32_t operand)
|
||||
{
|
||||
dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 0, 0);
|
||||
dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0);
|
||||
int err;
|
||||
|
||||
dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0);
|
||||
dsp563xx_write_dr_u32(tap, 0, operand, 24, 0);
|
||||
if ((err = dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 0, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = dsp563xx_write_dr_u32(tap, 0, opcode, 24, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = dsp563xx_once_ir_exec_nq(tap, DSP563XX_ONCE_OPDBR, 0, 1, 0)) != ERROR_OK)
|
||||
return err;
|
||||
if ((err = dsp563xx_write_dr_u32(tap, 0, operand, 24, 0)) != ERROR_OK)
|
||||
return err;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
|
|
@ -54,9 +54,29 @@
|
|||
#define DSP563XX_ONCE_OPABFR 0x00F /* pab fetch reg */
|
||||
#define DSP563XX_ONCE_OPABDR 0x010 /* pab decode reg */
|
||||
#define DSP563XX_ONCE_OPABEX 0x011 /* pab exec reg */
|
||||
#define DSP563XX_ONCE_OPABEX 0x011 /* trace buffer/inc ptr */
|
||||
#define DSP563XX_ONCE_OPABF11 0x012 /* trace buffer/inc ptr */
|
||||
#define DSP563XX_ONCE_NOREG 0x01F /* no register selected */
|
||||
|
||||
struct once_reg
|
||||
{
|
||||
uint8_t num;
|
||||
uint8_t addr;
|
||||
uint8_t len;
|
||||
const char *name;
|
||||
uint32_t reg;
|
||||
};
|
||||
|
||||
/** */
|
||||
int dsp563xx_once_request_debug(struct jtag_tap *tap, int reset_state);
|
||||
/** */
|
||||
int dsp563xx_once_target_status(struct jtag_tap *tap);
|
||||
|
||||
/** once read registers */
|
||||
int dsp563xx_once_read_register(struct jtag_tap *tap, struct once_reg *regs, int len);
|
||||
/** once read register */
|
||||
int dsp563xx_once_reg_read_ex_nq(struct jtag_tap *tap, uint8_t reg, uint8_t len, uint32_t * data);
|
||||
/** once read register */
|
||||
int dsp563xx_once_reg_read_ex(struct jtag_tap *tap, uint8_t reg, uint8_t len, uint32_t * data);
|
||||
/** once read register */
|
||||
int dsp563xx_once_reg_read(struct jtag_tap *tap, uint8_t reg, uint32_t * data);
|
||||
/** once write register */
|
||||
|
@ -64,12 +84,10 @@ int dsp563xx_once_reg_write(struct jtag_tap *tap, uint8_t reg, uint32_t data);
|
|||
/** single word instruction */
|
||||
int dsp563xx_once_execute_sw_ir(struct jtag_tap *tap, uint32_t opcode);
|
||||
/** double word instruction */
|
||||
int dsp563xx_once_execute_dw_ir(struct jtag_tap *tap, uint32_t opcode,
|
||||
uint32_t operand);
|
||||
int dsp563xx_once_execute_dw_ir(struct jtag_tap *tap, uint32_t opcode, uint32_t operand);
|
||||
/** single word instruction */
|
||||
int dsp563xx_once_execute_sw_ir_nq(struct jtag_tap *tap, uint32_t opcode);
|
||||
/** double word instruction */
|
||||
int dsp563xx_once_execute_dw_ir_nq(struct jtag_tap *tap, uint32_t opcode,
|
||||
uint32_t operand);
|
||||
int dsp563xx_once_execute_dw_ir_nq(struct jtag_tap *tap, uint32_t opcode, uint32_t operand);
|
||||
|
||||
#endif /* DSP563XX_ONCE_H */
|
||||
|
|
Loading…
Reference in New Issue