26 #define STACK_DEPTH 32
55 LOG_DEBUG(
"DEBUGMODULE: No memory access in progress!\n");
79 LOG_ERROR(
"Error: iparam size exceeds MIPS64_PRACC_PARAM_IN_SIZE");
84 LOG_ERROR(
"Error: unexpected reading of input parameter");
89 LOG_DEBUG(
"Reading %" PRIx64
" at %" PRIx64, data, address);
96 LOG_ERROR(
"Error: unexpected reading of output parameter");
101 LOG_DEBUG(
"Reading %" PRIx64
" at %" PRIx64, data, address);
111 LOG_DEBUG(
"Running commands %" PRIx64
" at %" PRIx64, data,
118 LOG_ERROR(
"Error reading from stack: stack is empty");
123 LOG_DEBUG(
"Reading %" PRIx64
" at %" PRIx64, data, address);
130 LOG_ERROR(
"Error reading unexpected address %" PRIx64, address);
178 LOG_DEBUG(
"Writing %" PRIx64
" at %" PRIx64, data, address);
184 LOG_ERROR(
"Error: unexpected writing of input parameter");
192 LOG_ERROR(
"Error: unexpected writing of output parameter");
199 LOG_ERROR(
"Error: PrAcc stack depth exceeded");
204 LOG_ERROR(
"Error writing unexpected address 0x%" PRIx64, address);
212 unsigned code_len,
const uint32_t *code,
213 unsigned num_param_in, uint64_t *param_in,
214 unsigned num_param_out, uint64_t *param_out)
217 uint64_t address = 0, address_prev = 0;
221 bool first_time_call =
true;
244 address_prev = address;
252 address = 0xffffffffff200000ull | address32;
254 int psz = (ejtag_ctrl >> 29) & 3;
255 int address20 = address & 7;
258 if (address20 != 7) {
259 LOG_ERROR(
"PSZ=%d ADDRESS[2:0]=%d: not supported", psz, address20);
265 if (address20 != 0 && address20 != 4) {
266 LOG_ERROR(
"PSZ=%d ADDRESS[2:0]=%d: not supported", psz, address20);
271 LOG_ERROR(
"PSZ=%d ADDRESS[2:0]=%d: not supported", psz, address20);
281 first_time_call =
false;
287 LOG_ERROR(
"mips64_pracc_exec_write() failed");
295 LOG_DEBUG(
"@MIPS64_PRACC_TEXT, address_prev=%" PRIx64, address_prev);
300 LOG_ERROR(
"mips64_pracc_exec_read() failed");
317 const uint32_t
code[] = {
348 uint64_t param_in[1];
353 ARRAY_SIZE(param_in), param_in, 1, (uint64_t *) buf);
357 unsigned count, uint64_t *buf)
361 for (
unsigned i = 0; i <
count; i++) {
372 const uint32_t
code[] = {
404 uint64_t param_in[1];
405 uint64_t param_out[1];
411 1, param_in, 1, param_out);
412 buf[0] = (uint32_t) param_out[0];
417 unsigned count, uint32_t *buf)
421 for (
unsigned i = 0; i <
count; i++) {
432 const uint32_t
code[] = {
464 uint64_t param_in[1];
465 uint64_t param_out[1];
471 1, param_in, 1, param_out);
472 buf[0] = (uint16_t)param_out[0];
477 unsigned count, uint16_t *buf)
481 for (
unsigned i = 0; i <
count; i++) {
492 const uint32_t
code[] = {
524 uint64_t param_in[1];
525 uint64_t param_out[1];
531 1, param_in, 1, param_out);
532 buf[0] = (uint8_t)param_out[0];
537 unsigned count, uint8_t *buf)
541 for (
unsigned i = 0; i <
count; i++) {
550 unsigned size,
unsigned count,
void *buf)
568 const uint32_t
code[] = {
605 uint64_t param_in[2];
615 uint64_t
addr,
unsigned count, uint64_t *buf)
619 for (
unsigned i = 0; i <
count; i++) {
630 const uint32_t
code[] = {
667 uint64_t param_in[1 + 1];
677 unsigned count, uint32_t *buf)
681 for (
unsigned i = 0; i <
count; i++) {
692 const uint32_t
code[] = {
727 uint64_t param_in[2];
737 uint64_t
addr,
unsigned count, uint16_t *buf)
741 for (
unsigned i = 0; i <
count; i++) {
752 const uint32_t
code[] = {
788 uint64_t param_in[2];
798 uint64_t
addr,
unsigned count, uint8_t *buf)
802 for (
unsigned i = 0; i <
count; i++) {
812 unsigned count,
void *buf)
829 const uint32_t
code[] = {
1039 const uint32_t
code[] = {
1272 bool write_t, uint64_t
addr,
1273 unsigned count, uint64_t *buf)
1275 uint32_t handler_code[] = {
1313 uint32_t jmp_code[] = {
1325 uint32_t ejtag_ctrl, address32;
1326 uint64_t address, val;
1353 LOG_DEBUG(
"daddiu: %08" PRIx32, handler_code[11]);
1366 address = 0xffffffffff200000ull | address32;
1388 unsigned num_clocks = 0;
1392 for (i = 0; i <
count; i++) {
1396 LOG_ERROR(
"mips64_ejtag_fastdata_scan failed");
1416 LOG_ERROR(
"mips_ejtag_drscan_32 failed");
1420 address = 0xffffffffff200000ull | address32;
1422 LOG_ERROR(
"mini program did not return to start");
unsigned int adapter_get_speed_khz(void)
Retrieves the clock speed of the adapter in kHz.
void jtag_add_clocks(int num_cycles)
Function jtag_add_clocks first checks that the state in which the clocks are to be issued is stable,...
int jtag_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
#define ERROR_JTAG_DEVICE_ERROR
static const struct @101 regs[]
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
#define MIPS64_MFC0(gpr, cpr, sel)
#define MIPS64_DMTC0(gpr, cpr, sel)
#define MIPS64_C0_XCONTEXT
#define MIPS64_SD(reg, off, base)
#define MIPS64_C0_COMPARE
#define MIPS64_SYNCI(reg, off)
#define MIPS64_NUM_CORE_REGS
#define MIPS64_LUI(reg, val)
#define MIPS64_DMTC1(gpr, cpr, sel)
#define MIPS64_NUM_CORE_C0_REGS
#define MIPS64_SH(reg, off, base)
#define MIPS64_BNE(src, tar, off)
#define MIPS64_C0_CONTEXT
#define MIPS64_C0_ENTRYLO0
#define MIPS64_CTC1(gpr, cpr, sel)
#define MIPS64_C0_BADVADDR
#define MIPS64_C1_FCONFIG
#define MIPS64_LW(reg, off, base)
#define MIPS64_LHU(reg, off, base)
#define MIPS64_C0_ENTRYLO1
#define MIPS64_DADDIU(tar, src, val)
#define MIPS64_ORI(src, tar, val)
#define MIPS64_DMFC0(gpr, cpr, sel)
#define MIPS64_LD(reg, off, base)
#define MIPS64_BEQ(src, tar, off)
#define MIPS64_ANDI(d, s, im)
#define MIPS64_LBU(reg, off, base)
#define MIPS64_C0_MEMCTRL
#define MIPS64_SRL(d, w, sh)
#define MIPS64_SW(reg, off, base)
#define MIPS64_SB(reg, off, base)
#define MIPS64_C0_PERFCOUNT
#define MIPS64_C0_CACHERR
#define MIPS64_MTC0(gpr, cpr, sel)
#define MIPS64_C0_ENTRYHI
#define MIPS64_CFC1(gpr, cpr, sel)
#define MIPS64_C0_PAGEMASK
#define MIPS64_DMFC1(gpr, cpr, sel)
static int mips64_pracc_write_u8(struct mips_ejtag *ejtag_info, uint64_t addr, uint8_t *buf)
static int mips64_pracc_read_mem8(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned count, uint8_t *buf)
static int mips64_pracc_read_mem32(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned count, uint32_t *buf)
static int mips64_pracc_write_mem16(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned count, uint16_t *buf)
static int mips64_pracc_write_mem64(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned count, uint64_t *buf)
static int mips64_pracc_exec_write(struct mips64_pracc_context *ctx, uint64_t address)
int mips64_pracc_write_regs(struct mips_ejtag *ejtag_info, uint64_t *regs)
static int mips64_pracc_write_mem32(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned count, uint32_t *buf)
int mips64_pracc_read_regs(struct mips_ejtag *ejtag_info, uint64_t *regs)
static int mips64_pracc_exec_read(struct mips64_pracc_context *ctx, uint64_t address)
static int mips64_pracc_read_mem64(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned count, uint64_t *buf)
static int wait_for_pracc_rw(struct mips_ejtag *ejtag_info, uint32_t *ctrl)
int mips64_pracc_write_mem(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned size, unsigned count, void *buf)
static int mips64_pracc_write_u16(struct mips_ejtag *ejtag_info, uint64_t addr, uint16_t *buf)
static int mips64_pracc_write_u64(struct mips_ejtag *ejtag_info, uint64_t addr, uint64_t *buf)
static int mips64_pracc_read_u8(struct mips_ejtag *ejtag_info, uint64_t addr, uint8_t *buf)
static int mips64_pracc_read_u32(struct mips_ejtag *ejtag_info, uint64_t addr, uint32_t *buf)
static int mips64_pracc_read_u64(struct mips_ejtag *ejtag_info, uint64_t addr, uint64_t *buf)
static int mips64_pracc_read_u16(struct mips_ejtag *ejtag_info, uint64_t addr, uint16_t *buf)
int mips64_pracc_exec(struct mips_ejtag *ejtag_info, unsigned code_len, const uint32_t *code, unsigned num_param_in, uint64_t *param_in, unsigned num_param_out, uint64_t *param_out)
static int mips64_pracc_write_u32(struct mips_ejtag *ejtag_info, uint64_t addr, uint32_t *buf)
static int mips64_pracc_read_mem16(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned count, uint16_t *buf)
int mips64_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_area *source, bool write_t, uint64_t addr, unsigned count, uint64_t *buf)
int mips64_pracc_read_mem(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned size, unsigned count, void *buf)
static int mips64_pracc_write_mem8(struct mips_ejtag *ejtag_info, uint64_t addr, unsigned count, uint8_t *buf)
#define MIPS64_PRACC_PARAM_OUT
#define MIPS64_PRACC_STACK
#define MIPS64_PRACC_ADDR_STEP
#define MIPS64_PRACC_PARAM_IN
#define MIPS64_PRACC_FASTDATA_AREA
#define MIPS64_PRACC_DATA_STEP
#define MIPS64_PRACC_TEXT
#define MIPS64_FASTDATA_HANDLER_SIZE
#define MIPS64_PRACC_PARAM_IN_SIZE
int mips_ejtag_drscan_64(struct mips_ejtag *ejtag_info, uint64_t *data)
void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, uint32_t new_instr)
int mips_ejtag_drscan_32(struct mips_ejtag *ejtag_info, uint32_t *data)
int mips64_ejtag_fastdata_scan(struct mips_ejtag *ejtag_info, bool write_t, uint64_t *data)
#define EJTAG_INST_CONTROL
#define EJTAG_INST_FASTDATA
#define EJTAG_INST_ADDRESS
struct rtt_control ctrl
Control block.
size_t size
Size of the control block search area.
struct mips_ejtag * ejtag_info
uint64_t stack[STACK_DEPTH]
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.