From 2e01a1ad1930aabb9e3bc7a0e3eb98b2b3331b1c Mon Sep 17 00:00:00 2001 From: mifi Date: Mon, 7 Jan 2008 17:11:11 +0000 Subject: - added gdb flash fixes patch https://lists.berlios.de/pipermail/openocd-development/2007-December/000548.html - added synthesize in_check_mask/value and error handler patch https://lists.berlios.de/pipermail/openocd-development/2008-January/000554.html (thanks to oyvind harboe for these patches) git-svn-id: svn://svn.berlios.de/openocd/trunk@248 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/target/arm7_9_common.c | 18 ++++++++--- src/target/arm_jtag.c | 14 ++++---- src/target/embeddedice.c | 3 +- src/target/etb.c | 6 ++-- src/target/etm.c | 3 +- src/target/xscale.c | 79 +++++++++++++++------------------------------- 6 files changed, 53 insertions(+), 70 deletions(-) (limited to 'src/target') diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index b5434d68..ee814ba9 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -577,7 +577,8 @@ int arm7_9_execute_sys_speed(struct target_s *target) int arm7_9_execute_fast_sys_speed(struct target_s *target) { - u8 check_value[4], check_mask[4]; + static int set=0; + static u8 check_value[4], check_mask[4]; armv4_5_common_t *armv4_5 = target->arch_info; arm7_9_common_t *arm7_9 = armv4_5->arch_info; @@ -588,9 +589,18 @@ int arm7_9_execute_fast_sys_speed(struct target_s *target) jtag_add_end_state(TAP_RTI); arm_jtag_set_instr(jtag_info, 0x4, NULL); - /* check for DBGACK and SYSCOMP set (others don't care) */ - buf_set_u32(check_value, 0, 32, 0x9); - buf_set_u32(check_mask, 0, 32, 0x9); + if (!set) + { + /* check for DBGACK and SYSCOMP set (others don't care) */ + + /* NB! These are constants that must be available until after next jtag_execute() and + we evaluate the values upon first execution in lieu of setting up these constants + during early setup. + */ + buf_set_u32(check_value, 0, 32, 0x9); + buf_set_u32(check_mask, 0, 32, 0x9); + set=1; + } /* read debug status register */ embeddedice_read_reg_w_check(dbg_stat, check_value, check_value); diff --git a/src/target/arm_jtag.c b/src/target/arm_jtag.c index 305590c8..f87f37a5 100644 --- a/src/target/arm_jtag.c +++ b/src/target/arm_jtag.c @@ -59,17 +59,20 @@ int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr, error_handler_t *ca field.in_handler = NULL; field.in_handler_priv = NULL; + + if (caller_error_handler) { - jtag_add_ir_scan(1, &field, -1, caller_error_handler); + jtag_set_check_value(&field, NULL, NULL, caller_error_handler); } else { error_handler_t error_handler; error_handler.error_handler = arm_jtag_set_instr_error_handler; error_handler.error_handler_priv = NULL; - jtag_add_ir_scan(1, &field, -1, &error_handler); + jtag_set_check_value(&field, NULL, NULL, &error_handler); } + jtag_add_ir_scan(1, &field, -1, NULL); free(field.out_value); @@ -94,13 +97,12 @@ int arm_jtag_scann(arm_jtag_t *jtag_info, u32 new_scan_chain) field.out_mask = NULL; field.in_value = NULL; #ifdef _ARM_JTAG_SCAN_N_CHECK_ - field.in_check_value = &scan_n_check_value; + jtag_set_check_value(&field, &scan_n_check_value, NULL, NULL, NULL); #else - field.in_check_value = NULL; -#endif - field.in_check_mask = NULL; field.in_handler = NULL; field.in_handler_priv = NULL; +#endif + arm_jtag_set_instr(jtag_info, jtag_info->scann_instr, NULL); jtag_add_dr_scan(1, &field, -1, NULL); diff --git a/src/target/embeddedice.c b/src/target/embeddedice.c index 11f2e6c2..3713fe95 100644 --- a/src/target/embeddedice.c +++ b/src/target/embeddedice.c @@ -259,8 +259,7 @@ int embeddedice_read_reg_w_check(reg_t *reg, u8* check_value, u8* check_mask) jtag_add_dr_scan(3, fields, -1, NULL); fields[0].in_value = reg->value; - fields[0].in_check_value = check_value; - fields[0].in_check_mask = check_mask; + jtag_set_check_value(fields+0, check_value, check_mask, NULL); /* when reading the DCC data register, leaving the address field set to * EICE_COMMS_DATA would read the register twice diff --git a/src/target/etb.c b/src/target/etb.c index 53f9f30e..0c409fb0 100644 --- a/src/target/etb.c +++ b/src/target/etb.c @@ -293,9 +293,9 @@ int etb_read_reg_w_check(reg_t *reg, u8* check_value, u8* check_mask) */ buf_set_u32(fields[1].out_value, 0, 7, 0x0); fields[0].in_value = reg->value; - fields[0].in_check_value = check_value; - fields[0].in_check_mask = check_mask; - + + jtag_set_check_value(fields+0, check_value, check_mask, NULL); + jtag_add_dr_scan(3, fields, -1, NULL); free(fields[1].out_value); diff --git a/src/target/etm.c b/src/target/etm.c index 0b8a8f5f..0d20b0d5 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -359,8 +359,7 @@ int etm_read_reg_w_check(reg_t *reg, u8* check_value, u8* check_mask) jtag_add_dr_scan(3, fields, -1, NULL); fields[0].in_value = reg->value; - fields[0].in_check_value = check_value; - fields[0].in_check_mask = check_mask; + jtag_set_check_value(fields+0, check_value, check_mask, NULL); jtag_add_dr_scan(3, fields, -1, NULL); diff --git a/src/target/xscale.c b/src/target/xscale.c index 13ecef1c..cb673df6 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -217,11 +217,8 @@ int xscale_jtag_set_instr(int chain_pos, u32 new_instr) buf_set_u32(field.out_value, 0, field.num_bits, new_instr); field.out_mask = NULL; field.in_value = NULL; - field.in_check_value = device->expected; - field.in_check_mask = device->expected_mask; - field.in_handler = NULL; - field.in_handler_priv = NULL; - + jtag_set_check_value(&field, device->expected, device->expected_mask, NULL); + jtag_add_ir_scan(1, &field, -1, NULL); free(field.out_value); @@ -275,10 +272,7 @@ int xscale_read_dcsr(target_t *target) fields[0].out_value = &field0; fields[0].out_mask = NULL; fields[0].in_value = NULL; - fields[0].in_check_value = &field0_check_value; - fields[0].in_check_mask = &field0_check_mask; - fields[0].in_handler = NULL; - fields[0].in_handler_priv = NULL; + jtag_set_check_value(fields+0, &field0_check_value, &field0_check_mask, NULL); fields[1].device = xscale->jtag_info.chain_pos; fields[1].num_bits = 32; @@ -289,16 +283,15 @@ int xscale_read_dcsr(target_t *target) fields[1].in_handler_priv = NULL; fields[1].in_check_value = NULL; fields[1].in_check_mask = NULL; + + fields[2].device = xscale->jtag_info.chain_pos; fields[2].num_bits = 1; fields[2].out_value = &field2; fields[2].out_mask = NULL; fields[2].in_value = NULL; - fields[2].in_check_value = &field2_check_value; - fields[2].in_check_mask = &field2_check_mask; - fields[2].in_handler = NULL; - fields[2].in_handler_priv = NULL; + jtag_set_check_value(fields+2, &field2_check_value, &field2_check_mask, NULL); jtag_add_dr_scan(3, fields, -1, NULL); @@ -354,10 +347,7 @@ int xscale_receive(target_t *target, u32 *buffer, int num_words) fields[0].out_value = NULL; fields[0].out_mask = NULL; /* fields[0].in_value = field0; */ - fields[0].in_check_value = &field0_check_value; - fields[0].in_check_mask = &field0_check_mask; - fields[0].in_handler = NULL; - fields[0].in_handler_priv = NULL; + jtag_set_check_value(fields+0, &field0_check_value, &field0_check_mask, NULL); fields[1].device = xscale->jtag_info.chain_pos; fields[1].num_bits = 32; @@ -368,16 +358,15 @@ int xscale_receive(target_t *target, u32 *buffer, int num_words) fields[1].in_handler_priv = NULL; fields[1].in_check_value = NULL; fields[1].in_check_mask = NULL; + + fields[2].device = xscale->jtag_info.chain_pos; fields[2].num_bits = 1; fields[2].out_value = NULL; fields[2].out_mask = NULL; fields[2].in_value = NULL; - fields[2].in_check_value = &field2_check_value; - fields[2].in_check_mask = &field2_check_mask; - fields[2].in_handler = NULL; - fields[2].in_handler_priv = NULL; + jtag_set_check_value(fields+2, &field2_check_value, &field2_check_mask, NULL); jtag_add_end_state(TAP_RTI); xscale_jtag_set_instr(xscale->jtag_info.chain_pos, xscale->jtag_info.dbgtx); @@ -460,10 +449,7 @@ int xscale_read_tx(target_t *target, int consume) fields[0].out_value = NULL; fields[0].out_mask = NULL; fields[0].in_value = &field0_in; - fields[0].in_check_value = &field0_check_value; - fields[0].in_check_mask = &field0_check_mask; - fields[0].in_handler = NULL; - fields[0].in_handler_priv = NULL; + jtag_set_check_value(fields+0, &field0_check_value, &field0_check_mask, NULL); fields[1].device = xscale->jtag_info.chain_pos; fields[1].num_bits = 32; @@ -474,16 +460,15 @@ int xscale_read_tx(target_t *target, int consume) fields[1].in_handler_priv = NULL; fields[1].in_check_value = NULL; fields[1].in_check_mask = NULL; + + fields[2].device = xscale->jtag_info.chain_pos; fields[2].num_bits = 1; fields[2].out_value = NULL; fields[2].out_mask = NULL; fields[2].in_value = NULL; - fields[2].in_check_value = &field2_check_value; - fields[2].in_check_mask = &field2_check_mask; - fields[2].in_handler = NULL; - fields[2].in_handler_priv = NULL; + jtag_set_check_value(fields+2, &field2_check_value, &field2_check_mask, NULL); gettimeofday(&timeout, NULL); timeval_add_time(&timeout, 5, 0); @@ -547,10 +532,7 @@ int xscale_write_rx(target_t *target) fields[0].out_value = &field0_out; fields[0].out_mask = NULL; fields[0].in_value = &field0_in; - fields[0].in_check_value = &field0_check_value; - fields[0].in_check_mask = &field0_check_mask; - fields[0].in_handler = NULL; - fields[0].in_handler_priv = NULL; + jtag_set_check_value(fields+0, &field0_check_value, &field0_check_mask, NULL); fields[1].device = xscale->jtag_info.chain_pos; fields[1].num_bits = 32; @@ -561,16 +543,15 @@ int xscale_write_rx(target_t *target) fields[1].in_handler_priv = NULL; fields[1].in_check_value = NULL; fields[1].in_check_mask = NULL; + + fields[2].device = xscale->jtag_info.chain_pos; fields[2].num_bits = 1; fields[2].out_value = &field2; fields[2].out_mask = NULL; fields[2].in_value = NULL; - fields[2].in_check_value = &field2_check_value; - fields[2].in_check_mask = &field2_check_mask; - fields[2].in_handler = NULL; - fields[2].in_handler_priv = NULL; + jtag_set_check_value(fields+2, &field2_check_value, &field2_check_mask, NULL); gettimeofday(&timeout, NULL); timeval_add_time(&timeout, 5, 0); @@ -637,10 +618,7 @@ int xscale_send(target_t *target, u8 *buffer, int count, int size) fields[0].out_value = &field0_out; fields[0].out_mask = NULL; fields[0].in_value = &field0_in; - fields[0].in_check_value = &field0_check_value; - fields[0].in_check_mask = &field0_check_mask; - fields[0].in_handler = NULL; - fields[0].in_handler_priv = NULL; + jtag_set_check_value(fields+0, &field0_check_value, &field0_check_mask, NULL); fields[1].device = xscale->jtag_info.chain_pos; fields[1].num_bits = 32; @@ -651,16 +629,15 @@ int xscale_send(target_t *target, u8 *buffer, int count, int size) fields[1].in_handler_priv = NULL; fields[1].in_check_value = NULL; fields[1].in_check_mask = NULL; + + fields[2].device = xscale->jtag_info.chain_pos; fields[2].num_bits = 1; fields[2].out_value = &field2; fields[2].out_mask = NULL; fields[2].in_value = NULL; - fields[2].in_check_value = &field2_check_value; - fields[2].in_check_mask = &field2_check_mask; - fields[2].in_handler = NULL; - fields[2].in_handler_priv = NULL; + jtag_set_check_value(fields+2, &field2_check_value, &field2_check_mask, NULL); while (done_count++ < count) { @@ -737,10 +714,7 @@ int xscale_write_dcsr(target_t *target, int hold_rst, int ext_dbg_brk) fields[0].out_value = &field0; fields[0].out_mask = NULL; fields[0].in_value = NULL; - fields[0].in_check_value = &field0_check_value; - fields[0].in_check_mask = &field0_check_mask; - fields[0].in_handler = NULL; - fields[0].in_handler_priv = NULL; + jtag_set_check_value(fields+0, &field0_check_value, &field0_check_mask, NULL); fields[1].device = xscale->jtag_info.chain_pos; fields[1].num_bits = 32; @@ -751,16 +725,15 @@ int xscale_write_dcsr(target_t *target, int hold_rst, int ext_dbg_brk) fields[1].in_handler_priv = NULL; fields[1].in_check_value = NULL; fields[1].in_check_mask = NULL; + + fields[2].device = xscale->jtag_info.chain_pos; fields[2].num_bits = 1; fields[2].out_value = &field2; fields[2].out_mask = NULL; fields[2].in_value = NULL; - fields[2].in_check_value = &field2_check_value; - fields[2].in_check_mask = &field2_check_mask; - fields[2].in_handler = NULL; - fields[2].in_handler_priv = NULL; + jtag_set_check_value(fields+2, &field2_check_value, &field2_check_mask, NULL); jtag_add_dr_scan(3, fields, -1, NULL); -- cgit v1.2.3