X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Ftarget%2Farm11.c;h=cbe4d4503f8473e1b00766897fb03486bf7cf407;hp=1ff623499b7551c8e7da483f5201e1a86efe29a2;hb=5be455a710c57bbbbd49c2d671b42098db7be5dc;hpb=08d4411b59dd8bd0e7d8009003b71d23acbf6eee diff --git a/src/target/arm11.c b/src/target/arm11.c index 1ff623499b..cbe4d4503f 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -19,9 +19,7 @@ * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * along with this program. If not, see . * ***************************************************************************/ #ifdef HAVE_CONFIG_H @@ -363,15 +361,6 @@ static int arm11_arch_state(struct target *target) return retval; } -/* target request support */ -static int arm11_target_request_data(struct target *target, - uint32_t size, uint8_t *buffer) -{ - LOG_WARNING("Not implemented: %s", __func__); - - return ERROR_FAIL; -} - /* target execution control */ static int arm11_halt(struct target *target) { @@ -401,7 +390,7 @@ static int arm11_halt(struct target *target) break; - long long then = 0; + int64_t then = 0; if (i == 1000) then = timeval_ms(); if (i >= 1000) { @@ -429,11 +418,33 @@ static uint32_t arm11_nextpc(struct arm11_common *arm11, int current, uint32_t a { void *value = arm11->arm.pc->value; - if (!current) - buf_set_u32(value, 0, 32, address); - else + /* use the current program counter */ + if (current) address = buf_get_u32(value, 0, 32); + /* Make sure that the gdb thumb fixup does not + * kill the return address + */ + switch (arm11->arm.core_state) { + case ARM_STATE_ARM: + address &= 0xFFFFFFFC; + break; + case ARM_STATE_THUMB: + /* When the return address is loaded into PC + * bit 0 must be 1 to stay in Thumb state + */ + address |= 0x1; + break; + + /* catch-all for JAZELLE and THUMB_EE */ + default: + break; + } + + buf_set_u32(value, 0, 32, address); + arm11->arm.pc->dirty = 1; + arm11->arm.pc->valid = 1; + return address; } @@ -523,7 +534,7 @@ static int arm11_resume(struct target *target, int current, break; - long long then = 0; + int64_t then = 0; if (i == 1000) then = timeval_ms(); if (i >= 1000) { @@ -703,21 +714,32 @@ static int arm11_assert_reset(struct target *target) { struct arm11_common *arm11 = target_to_arm11(target); - /* optionally catch reset vector */ - if (target->reset_halt && !(arm11->vcr & 1)) - CHECK_RETVAL(arm11_sc7_set_vcr(arm11, arm11->vcr | 1)); - - /* Issue some kind of warm reset. */ - if (target_has_event_action(target, TARGET_EVENT_RESET_ASSERT)) - target_handle_event(target, TARGET_EVENT_RESET_ASSERT); - else if (jtag_get_reset_config() & RESET_HAS_SRST) { - /* REVISIT handle "pulls" cases, if there's - * hardware that needs them to work. - */ - jtag_add_reset(0, 1); + if (!(target_was_examined(target))) { + if (jtag_get_reset_config() & RESET_HAS_SRST) + jtag_add_reset(0, 1); + else { + LOG_WARNING("Reset is not asserted because the target is not examined."); + LOG_WARNING("Use a reset button or power cycle the target."); + return ERROR_TARGET_NOT_EXAMINED; + } } else { - LOG_ERROR("%s: how to reset?", target_name(target)); - return ERROR_FAIL; + + /* optionally catch reset vector */ + if (target->reset_halt && !(arm11->vcr & 1)) + CHECK_RETVAL(arm11_sc7_set_vcr(arm11, arm11->vcr | 1)); + + /* Issue some kind of warm reset. */ + if (target_has_event_action(target, TARGET_EVENT_RESET_ASSERT)) + target_handle_event(target, TARGET_EVENT_RESET_ASSERT); + else if (jtag_get_reset_config() & RESET_HAS_SRST) { + /* REVISIT handle "pulls" cases, if there's + * hardware that needs them to work. + */ + jtag_add_reset(0, 1); + } else { + LOG_ERROR("%s: how to reset?", target_name(target)); + return ERROR_FAIL; + } } /* registers are now invalid */ @@ -771,13 +793,6 @@ static int arm11_deassert_reset(struct target *target) return ERROR_OK; } -static int arm11_soft_reset_halt(struct target *target) -{ - LOG_WARNING("Not implemented: %s", __func__); - - return ERROR_FAIL; -} - /* target memory access * size: 1 = byte (8bit), 2 = half-word (16bit), 4 = word (32bit) * count: number of items of @@ -1193,6 +1208,12 @@ static int arm11_examine(struct target *target) LOG_DEBUG("IDCODE %08" PRIx32 " IMPLEMENTOR %02x DIDR %08" PRIx32, device_id, implementor, didr); + /* Build register cache "late", after target_init(), since we + * want to know if this core supports Secure Monitor mode. + */ + if (!target_was_examined(target)) + CHECK_RETVAL(arm11_dpm_init(arm11, didr)); + /* as a side-effect this reads DSCR and thus * clears the ARM11_DSCR_STICKY_PRECISE_DATA_ABORT / Sticky Precise Data Abort Flag * as suggested by the spec. @@ -1202,12 +1223,6 @@ static int arm11_examine(struct target *target) if (retval != ERROR_OK) return retval; - /* Build register cache "late", after target_init(), since we - * want to know if this core supports Secure Monitor mode. - */ - if (!target_was_examined(target)) - CHECK_RETVAL(arm11_dpm_init(arm11, didr)); - /* ETM on ARM11 still uses original scanchain 6 access mode */ if (arm11->arm.etm && !target_was_examined(target)) { *register_get_last_cache_p(&target->reg_cache) = @@ -1340,15 +1355,12 @@ struct target_type arm11_target = { .poll = arm11_poll, .arch_state = arm11_arch_state, - .target_request_data = arm11_target_request_data, - .halt = arm11_halt, .resume = arm11_resume, .step = arm11_step, .assert_reset = arm11_assert_reset, .deassert_reset = arm11_deassert_reset, - .soft_reset_halt = arm11_soft_reset_halt, .get_gdb_reg_list = arm_get_gdb_reg_list,