85 LOG_DEBUG(
"DEBUGMODULE: No memory access in progress!");
119 for (
int i = 0; i != 5; i++) {
127 uint32_t data = (i == 3) ? jt_code :
MIPS32_NOP;
134 if (ejtag_info->
mode != 0)
137 for (
int i = 0; i != 2; i++) {
154 uint32_t *param_out,
bool check_last)
157 int store_pending = 0;
158 uint32_t max_store_addr = 0;
160 int restart_count = 0;
162 bool final_check = 0;
168 if (restart_count < 3) {
187 if (store_pending == 0) {
189 if (code_count < 2) {
197 ejtag_info->
pa_addr > max_store_addr) {
217 LOG_DEBUG(
"reading at unexpected address %" PRIx32
", expected %x",
222 restart_count == 0) {
223 LOG_DEBUG(
"restarting, without clean jump");
227 }
else if (code_count < 2) {
235 if (store_addr != 0) {
236 if (store_addr > max_store_addr)
237 max_store_addr = store_addr;
249 if (store_pending == 0)
254 LOG_DEBUG(
"unexpected second pass through pracc text");
259 LOG_DEBUG(
"unexpected read address in final check: %"
260 PRIx32
", expected: %x", ejtag_info->
pa_addr,
267 LOG_DEBUG(
"failed to jump back to pracc text");
271 if (code_count > 10) {
272 LOG_DEBUG(
"execution abandoned, store pending: %d", store_pending);
286 if (final_check && !check_last)
289 if (store_pending == 0 && pass) {
290 LOG_DEBUG(
"warning: store access pass pracc text");
328 if (
LOWER16(data) == 0 && optimize)
330 else if (
UPPER16(data) == 0 && optimize)
344 uint32_t *buf,
bool check_last)
355 if (ejtag_info->
mode == 0)
372 unsigned num_clocks =
382 scan_in[scan_count++].scan_96);
399 ejtag_ctrl =
buf_get_u32(scan_in[scan_count].scan_32.ctrl, 0, 32);
402 LOG_ERROR(
"Error: access not pending count: %d", scan_count);
407 LOG_ERROR(
"Not a fetch/read access, count: %d", scan_count);
411 if (
addr != fetch_addr) {
412 LOG_ERROR(
"Fetch addr mismatch, read: %" PRIx32
" expected: %" PRIx32
" count: %d",
413 addr, fetch_addr, scan_count);
423 ejtag_ctrl =
buf_get_u32(scan_in[scan_count].scan_32.ctrl, 0, 32);
427 LOG_ERROR(
"Not a store/write access, count: %d", scan_count);
431 if (
addr != store_addr) {
432 LOG_ERROR(
"Store address mismatch, read: %" PRIx32
" expected: %" PRIx32
" count: %d",
433 addr, store_addr, scan_count);
438 buf[buf_index] =
buf_get_u32(scan_in[scan_count].scan_32.data, 0, 32);
474 uint32_t *data =
NULL;
476 data = malloc(256 *
sizeof(uint32_t));
483 uint32_t *buf32 = buf;
484 uint16_t *buf16 = buf;
491 int this_round_count = (
count > 256) ? 256 :
count;
492 uint32_t last_upper_base_addr =
UPPER16((
addr + 0x8000));
497 for (
int i = 0; i != this_round_count; i++) {
498 uint32_t upper_base_addr =
UPPER16((
addr + 0x8000));
499 if (last_upper_base_addr != upper_base_addr) {
501 last_upper_base_addr = upper_base_addr;
525 buf32 += this_round_count;
531 uint32_t *data_p = data;
532 for (
int i = 0; i != this_round_count; i++) {
534 *buf16++ = *data_p++;
539 count -= this_round_count;
610 uint32_t start_addr, uint32_t end_addr,
int cached,
int rel)
659 start_addr |= clsiz - 1;
660 end_addr |= clsiz - 1;
666 uint32_t last_upper_base_addr =
UPPER16((start_addr + 0x8000));
670 while (start_addr <= end_addr) {
671 uint32_t upper_base_addr =
UPPER16((start_addr + 0x8000));
672 if (last_upper_base_addr != upper_base_addr) {
674 last_upper_base_addr = upper_base_addr;
689 if (
count == 256 && start_addr <= end_addr) {
718 const uint32_t *buf32 = buf;
719 const uint16_t *buf16 = buf;
720 const uint8_t *buf8 = buf;
726 int this_round_count = (
count > 128) ? 128 :
count;
727 uint32_t last_upper_base_addr =
UPPER16((
addr + 0x8000));
731 for (
int i = 0; i != this_round_count; i++) {
732 uint32_t upper_base_addr =
UPPER16((
addr + 0x8000));
733 if (last_upper_base_addr != upper_base_addr) {
735 last_upper_base_addr = upper_base_addr;
743 }
else if (
size == 2) {
764 count -= this_round_count;
812 if (cached == 3 || cached == 0) {
813 uint32_t start_addr =
addr;
817 LOG_DEBUG(
"Unknown release in cache code");
831 uint32_t cp0_write_code[] = {
841 for (
int i = 2; i < 32; i++)
844 for (
int i = 0; i != 6; i++) {
866 uint32_t cp0_read_code[] = {
878 for (
int i = 2; i != 32; i++)
882 for (
int i = 0; i != 6; i++) {
911 int write_t, uint32_t
addr,
int count, uint32_t *buf)
914 uint32_t handler_code[] = {
956 uint32_t jmp_code[] = {
966 for (
unsigned i = 0; i <
ARRAY_SIZE(jmp_code); i++) {
1001 unsigned num_clocks = 0;
1005 for (
int i = 0; i <
count; i++) {
1021 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.
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned first, unsigned num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
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 KUSEG
Memory segments (32bit kernel mode addresses) These are the traditional names used in the 32-bit univ...
#define MIPS32_ADDI(isa, tar, src, val)
#define MIPS32_MFHI(isa, reg)
#define MIPS32_SYNCI_STEP
#define MIPS32_MTHI(isa, reg)
#define MIPS32_CONFIG0_K0_SHIFT
#define MIPS32_CONFIG0_AR_SHIFT
#define MIPS32_BNE(isa, src, tar, off)
#define KSEGX(a)
Returns the kernel segment base of a given address.
#define MIPS32_CONFIG1_DL_MASK
#define MIPS32_RDHWR(isa, tar, dst)
#define MIPS32_CONFIG0_KU_MASK
#define MIPS32_XORI(isa, tar, src, val)
#define MIPS32_SW(isa, reg, off, base)
#define MIPS32_MTLO(isa, reg)
#define MIPS32_CACHE_D_HIT_WRITEBACK
Cache operations definitions Operation field is 5 bits long : 1) bits 1..0 hold cache type 2) bits 4....
#define MIPS32_J(isa, tar)
#define MIPS32_LBU(isa, reg, off, base)
#define MIPS32_LHU(isa, reg, off, base)
#define MIPS32_CONFIG0_K23_SHIFT
#define MIPS32_MFLO(isa, reg)
#define MIPS32_CONFIG0_KU_SHIFT
CP0 CONFIG register fields.
#define MIPS32_SB(isa, reg, off, base)
#define MIPS32_CONFIG0_K23_MASK
#define MIPS32_SH(isa, reg, off, base)
#define MIPS32_MTC0(isa, gpr, cpr, sel)
#define MIPS32_CONFIG1_DL_SHIFT
#define MIPS32_CACHE_I_HIT_INVALIDATE
#define MIPS32_LUI(isa, reg, val)
#define MIPS32_CACHE(isa, op, off, base)
#define MIPS32_CONFIG0_AR_MASK
#define MIPS32_SYNCI(isa, off, base)
#define MIPS32_ORI(isa, tar, src, val)
#define MIPS32_MFC0(isa, gpr, cpr, sel)
#define MIPS32_JR(isa, reg)
#define MIPS32_B(isa, off)
#define MIPS32_LW(isa, reg, off, base)
#define MIPS32_CONFIG0_K0_MASK
static int mips32_pracc_read_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_t *buf)
void pracc_queue_free(struct pracc_queue_info *ctx)
static int wait_for_pracc_rw(struct mips_ejtag *ejtag_info)
static int mips32_pracc_read_ctrl_addr(struct mips_ejtag *ejtag_info)
int mips32_pracc_write_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, const void *buf)
static int mips32_pracc_exec(struct mips_ejtag *ejtag_info, struct pracc_queue_info *ctx, uint32_t *param_out, bool check_last)
int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_area *source, int write_t, uint32_t addr, int count, uint32_t *buf)
static void pracc_add_li32(struct pracc_queue_info *ctx, uint32_t reg_num, uint32_t data, bool optimize)
int mips32_pracc_queue_exec(struct mips_ejtag *ejtag_info, struct pracc_queue_info *ctx, uint32_t *buf, bool check_last)
static int mips32_pracc_synchronize_cache(struct mips_ejtag *ejtag_info, uint32_t start_addr, uint32_t end_addr, int cached, int rel)
mips32_pracc_sync_cache
void pracc_queue_init(struct pracc_queue_info *ctx)
int mips32_pracc_read_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, void *buf)
static int mips32_pracc_write_mem_generic(struct mips_ejtag *ejtag_info, uint32_t addr, int size, int count, const void *buf)
static void mips32_pracc_finish(struct mips_ejtag *ejtag_info)
static int mips32_pracc_clean_text_jump(struct mips_ejtag *ejtag_info)
int mips32_pracc_read_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
int mips32_pracc_write_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
int mips32_cp0_read(struct mips_ejtag *ejtag_info, uint32_t *val, uint32_t cp0_reg, uint32_t cp0_sel)
mips32_cp0_read
void pracc_add(struct pracc_queue_info *ctx, uint32_t addr, uint32_t instr)
int mips32_cp0_write(struct mips_ejtag *ejtag_info, uint32_t val, uint32_t cp0_reg, uint32_t cp0_sel)
mips32_cp0_write
#define MIPS32_PRACC_TEXT
#define PRACC_UPPER_BASE_ADDR
#define MIPS32_FASTDATA_HANDLER_SIZE
static void pracc_swap16_array(struct mips_ejtag *ejtag_info, uint32_t *buf, int count)
#define MIPS32_PRACC_FASTDATA_AREA
#define MIPS32_PRACC_PARAM_OUT
int mips_ejtag_fastdata_scan(struct mips_ejtag *ejtag_info, int write_t, uint32_t *data)
void mips_ejtag_drscan_32_out(struct mips_ejtag *ejtag_info, uint32_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)
void mips_ejtag_add_scan_96(struct mips_ejtag *ejtag_info, uint32_t ctrl, uint32_t data, uint8_t *in_scan_buf)
#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 pa_list * pracc_list
struct mips_ejtag * ejtag_info
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.