]> git.sur5r.net Git - openocd/blobdiff - src/target/armv4_5.c
cortex a8: add missing error handling
[openocd] / src / target / armv4_5.c
index 36101b0208a6ebcc71d10852bc77b96638029f38..1a84a5f4e77b34680e06f4ff7c0ff3a07c054545 100644 (file)
@@ -217,7 +217,7 @@ enum arm_mode armv4_5_number_to_mode(int number)
        }
 }
 
-const char *arm_state_strings[] =
+static const char *arm_state_strings[] =
 {
        "ARM", "Thumb", "Jazelle", "ThumbEE",
 };
@@ -820,11 +820,9 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        struct arm *arm;
        int retval;
 
-       context = Jim_GetAssocData(interp, "context");
-       if (context == NULL) {
-               LOG_ERROR("%s: no command context", __func__);
-               return JIM_ERR;
-       }
+       context = current_command_context(interp);
+       assert( context != NULL);
+
        target = get_current_target(context);
        if (target == NULL) {
                LOG_ERROR("%s: no current target", __func__);
@@ -840,13 +838,6 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                return JIM_ERR;
        }
 
-       if (arm->core_type == ARM_MODE_THREAD)
-       {
-               /* armv7m not supported */
-               LOG_ERROR("Unsupported Command");
-               return ERROR_OK;
-       }
-
        if ((argc < 6) || (argc > 7)) {
                /* FIXME use the command name to verify # params... */
                LOG_ERROR("%s: wrong number of arguments", __func__);
@@ -951,6 +942,49 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        return JIM_OK;
 }
 
+COMMAND_HANDLER(handle_arm_semihosting_command)
+{
+       struct target *target = get_current_target(CMD_CTX);
+       struct arm *arm = target ? target_to_arm(target) : NULL;
+
+       if (!is_arm(arm)) {
+               command_print(CMD_CTX, "current target isn't an ARM");
+               return ERROR_FAIL;
+       }
+
+       if (!arm->setup_semihosting)
+       {
+               command_print(CMD_CTX, "semihosting not supported for current target");
+       }
+
+       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 (arm->setup_semihosting(target, semihosting) != ERROR_OK) {
+                       LOG_ERROR("Failed to Configure semihosting");
+                       return ERROR_FAIL;
+               }
+
+               /* FIXME never let that "catch" be dropped! */
+               arm->is_semihosting = semihosting;
+       }
+
+       command_print(CMD_CTX, "semihosting is %s",
+                       arm->is_semihosting
+                       ? "enabled" : "disabled");
+
+       return ERROR_OK;
+}
+
 static const struct command_registration arm_exec_command_handlers[] = {
        {
                .name = "reg",
@@ -985,6 +1019,13 @@ static const struct command_registration arm_exec_command_handlers[] = {
                .help = "read coprocessor register",
                .usage = "cpnum op1 CRn op2 CRm",
        },
+       {
+               "semihosting",
+               .handler = handle_arm_semihosting_command,
+               .mode = COMMAND_EXEC,
+               .usage = "['enable'|'disable']",
+               .help = "activate support for semihosting operations",
+       },
 
        COMMAND_REGISTRATION_DONE
 };