jtag: retire jtag_get/set_end_state()
[fw/openocd] / src / target / arm7_9_common.c
index 2176729182b98d98f5e76de0fac331873b265a1e..8f63f3c0ae547cb24845720a1a0daf93a8061995 100644 (file)
@@ -687,12 +687,11 @@ int arm7_9_execute_sys_speed(struct target *target)
        struct reg *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
 
        /* set RESTART instruction */
-       jtag_set_end_state(TAP_IDLE);
        if (arm7_9->need_bypass_before_restart) {
                arm7_9->need_bypass_before_restart = 0;
-               arm_jtag_set_instr(jtag_info, 0xf, NULL);
+               arm_jtag_set_instr(jtag_info, 0xf, NULL, TAP_IDLE);
        }
-       arm_jtag_set_instr(jtag_info, 0x4, NULL);
+       arm_jtag_set_instr(jtag_info, 0x4, NULL, TAP_IDLE);
 
        long long then = timeval_ms();
        int timeout;
@@ -740,12 +739,11 @@ int arm7_9_execute_fast_sys_speed(struct target *target)
        struct reg *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
 
        /* set RESTART instruction */
-       jtag_set_end_state(TAP_IDLE);
        if (arm7_9->need_bypass_before_restart) {
                arm7_9->need_bypass_before_restart = 0;
-               arm_jtag_set_instr(jtag_info, 0xf, NULL);
+               arm_jtag_set_instr(jtag_info, 0xf, NULL, TAP_IDLE);
        }
-       arm_jtag_set_instr(jtag_info, 0x4, NULL);
+       arm_jtag_set_instr(jtag_info, 0x4, NULL, TAP_IDLE);
 
        if (!set)
        {
@@ -995,7 +993,7 @@ int arm7_9_assert_reset(struct target *target)
                         * certain ARM9 cores (maybe more) - AT91SAM9260
                         * and STR9
                         */
-                       jtag_add_runtest(1, jtag_get_end_state());
+                       jtag_add_runtest(1, TAP_IDLE);
                }
                else
                {
@@ -1726,9 +1724,6 @@ int arm7_9_restore_context(struct target *target)
        arm7_9->write_pc(target, buf_get_u32(armv4_5->pc->value, 0, 32));
        armv4_5->pc->dirty = 0;
 
-       if (arm7_9->post_restore_context)
-               arm7_9->post_restore_context(target);
-
        return ERROR_OK;
 }
 
@@ -1746,14 +1741,13 @@ int arm7_9_restart_core(struct target *target)
        struct arm_jtag *jtag_info = &arm7_9->jtag_info;
 
        /* set RESTART instruction */
-       jtag_set_end_state(TAP_IDLE);
        if (arm7_9->need_bypass_before_restart) {
                arm7_9->need_bypass_before_restart = 0;
-               arm_jtag_set_instr(jtag_info, 0xf, NULL);
+               arm_jtag_set_instr(jtag_info, 0xf, NULL, TAP_IDLE);
        }
-       arm_jtag_set_instr(jtag_info, 0x4, NULL);
+       arm_jtag_set_instr(jtag_info, 0x4, NULL, TAP_IDLE);
 
-       jtag_add_runtest(1, jtag_set_end_state(TAP_IDLE));
+       jtag_add_runtest(1, TAP_IDLE);
        return jtag_execute_queue();
 }
 
@@ -2834,54 +2828,32 @@ COMMAND_HANDLER(handle_arm7_9_dcc_downloads_command)
        return ERROR_OK;
 }
 
-COMMAND_HANDLER(handle_arm7_9_semihosting_command)
+int arm7_9_setup_semihosting(struct target *target, int enable)
 {
-       struct target *target = get_current_target(CMD_CTX);
        struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
 
        if (!is_arm7_9(arm7_9))
        {
-               command_print(CMD_CTX, "current target isn't an ARM7/ARM9 target");
+               LOG_USER("current target isn't an ARM7/ARM9 target");
                return ERROR_TARGET_INVALID;
        }
 
-       if (CMD_ARGC > 0)
-       {
-               int semihosting;
-
-               COMMAND_PARSE_ENABLE(CMD_ARGV[0], semihosting);
-
-               if (!target_was_examined(target))
-               {
-                       LOG_ERROR("Target not examined yet");
-                       return ERROR_FAIL;
-               }
-
-               if (arm7_9->has_vector_catch) {
-                       struct reg *vector_catch = &arm7_9->eice_cache
-                                       ->reg_list[EICE_VEC_CATCH];
-
-                       if (!vector_catch->valid)
-                               embeddedice_read_reg(vector_catch);
-                       buf_set_u32(vector_catch->value, 2, 1, semihosting);
-                       embeddedice_store_reg(vector_catch);
-               } else {
-                       /* TODO: allow optional high vectors and/or BKPT_HARD */
-                       if (semihosting)
-                               breakpoint_add(target, 8, 4, BKPT_SOFT);
-                       else
-                               breakpoint_remove(target, 8); 
-               }
-
-               /* FIXME never let that "catch" be dropped! */
-               arm7_9->armv4_5_common.is_semihosting = semihosting;
+       if (arm7_9->has_vector_catch) {
+               struct reg *vector_catch = &arm7_9->eice_cache
+                               ->reg_list[EICE_VEC_CATCH];
 
+               if (!vector_catch->valid)
+                       embeddedice_read_reg(vector_catch);
+               buf_set_u32(vector_catch->value, 2, 1, enable);
+               embeddedice_store_reg(vector_catch);
+       } else {
+               /* TODO: allow optional high vectors and/or BKPT_HARD */
+               if (enable)
+                       breakpoint_add(target, 8, 4, BKPT_SOFT);
+               else
+                       breakpoint_remove(target, 8);
        }
 
-       command_print(CMD_CTX, "semihosting is %s",
-                       arm7_9->armv4_5_common.is_semihosting
-                       ? "enabled" : "disabled");
-
        return ERROR_OK;
 }
 
@@ -2906,6 +2878,7 @@ int arm7_9_init_arch_info(struct target *target, struct arm7_9_common *arm7_9)
        armv4_5->read_core_reg = arm7_9_read_core_reg;
        armv4_5->write_core_reg = arm7_9_write_core_reg;
        armv4_5->full_context = arm7_9_full_context;
+       armv4_5->setup_semihosting = arm7_9_setup_semihosting;
 
        retval = arm_init_arch_info(target, armv4_5);
        if (retval != ERROR_OK)
@@ -2939,13 +2912,6 @@ static const struct command_registration arm7_9_any_command_handlers[] = {
                .usage = "['enable'|'disable']",
                .help = "use DCC downloads for larger memory writes",
        },
-       {
-               "semihosting",
-               .handler = handle_arm7_9_semihosting_command,
-               .mode = COMMAND_EXEC,
-               .usage = "['enable'|'disable']",
-               .help = "activate support for semihosting operations",
-       },
        COMMAND_REGISTRATION_DONE
 };
 const struct command_registration arm7_9_command_handlers[] = {