use COMMAND_REGISTER macro
[fw/openocd] / src / target / oocd_trace.c
index c5f8b808ad88958f29e93e85ceebf7417b4bf284..596a4d60d9847373d1fcdf39cbdd2eb18ec06832 100644 (file)
@@ -30,7 +30,7 @@
  */
 
 
-static int oocd_trace_register_commands(struct command_context_s *cmd_ctx);
+static int oocd_trace_register_commands(struct command_context *cmd_ctx);
 
 static int oocd_trace_read_reg(struct oocd_trace *oocd_trace, int reg, uint32_t *value)
 {
@@ -96,7 +96,7 @@ static int oocd_trace_read_memory(struct oocd_trace *oocd_trace, uint8_t *data,
        return ERROR_OK;
 }
 
-static int oocd_trace_init(etm_context_t *etm_ctx)
+static int oocd_trace_init(struct etm_context *etm_ctx)
 {
        uint8_t trash[256];
        struct oocd_trace *oocd_trace = etm_ctx->capture_driver_priv;
@@ -143,7 +143,7 @@ static int oocd_trace_init(etm_context_t *etm_ctx)
        return ERROR_OK;
 }
 
-static trace_status_t oocd_trace_status(etm_context_t *etm_ctx)
+static trace_status_t oocd_trace_status(struct etm_context *etm_ctx)
 {
        struct oocd_trace *oocd_trace = etm_ctx->capture_driver_priv;
        uint32_t status;
@@ -175,7 +175,7 @@ static trace_status_t oocd_trace_status(etm_context_t *etm_ctx)
        return etm_ctx->capture_status;
 }
 
-static int oocd_trace_read_trace(etm_context_t *etm_ctx)
+static int oocd_trace_read_trace(struct etm_context *etm_ctx)
 {
        struct oocd_trace *oocd_trace = etm_ctx->capture_driver_priv;
        uint32_t status, address;
@@ -233,7 +233,7 @@ static int oocd_trace_read_trace(etm_context_t *etm_ctx)
        return ERROR_OK;
 }
 
-static int oocd_trace_start_capture(etm_context_t *etm_ctx)
+static int oocd_trace_start_capture(struct etm_context *etm_ctx)
 {
        struct oocd_trace *oocd_trace = etm_ctx->capture_driver_priv;
        uint32_t control = 0x1; /* 0x1: enabled */
@@ -266,7 +266,7 @@ static int oocd_trace_start_capture(etm_context_t *etm_ctx)
        return ERROR_OK;
 }
 
-static int oocd_trace_stop_capture(etm_context_t *etm_ctx)
+static int oocd_trace_stop_capture(struct etm_context *etm_ctx)
 {
        struct oocd_trace *oocd_trace = etm_ctx->capture_driver_priv;
 
@@ -291,20 +291,20 @@ struct etm_capture_driver oocd_trace_capture_driver =
 
 COMMAND_HANDLER(handle_oocd_trace_config_command)
 {
-       target_t *target;
+       struct target *target;
        struct arm *arm;
 
-       if (argc != 2)
+       if (CMD_ARGC != 2)
        {
                LOG_ERROR("incomplete 'oocd_trace config <target> <tty>' command");
                return ERROR_FAIL;
        }
 
-       target = get_current_target(cmd_ctx);
+       target = get_current_target(CMD_CTX);
        arm = target_to_arm(target);
        if (!is_arm(arm))
        {
-               command_print(cmd_ctx, "current target isn't an ARM");
+               command_print(CMD_CTX, "current target isn't an ARM");
                return ERROR_FAIL;
        }
 
@@ -316,7 +316,7 @@ COMMAND_HANDLER(handle_oocd_trace_config_command)
                oocd_trace->etm_ctx = arm->etm;
 
                /* copy name of TTY device used to communicate with OpenOCD + trace */
-               oocd_trace->tty = strndup(args[1], 256);
+               oocd_trace->tty = strndup(CMD_ARGV[1], 256);
        }
        else
        {
@@ -328,29 +328,29 @@ COMMAND_HANDLER(handle_oocd_trace_config_command)
 
 COMMAND_HANDLER(handle_oocd_trace_status_command)
 {
-       target_t *target;
+       struct target *target;
        struct arm *arm;
        struct oocd_trace *oocd_trace;
        uint32_t status;
 
-       target = get_current_target(cmd_ctx);
+       target = get_current_target(CMD_CTX);
 
        arm = target_to_arm(target);
        if (!is_arm(arm))
        {
-               command_print(cmd_ctx, "current target isn't an ARM");
+               command_print(CMD_CTX, "current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        if (!arm->etm)
        {
-               command_print(cmd_ctx, "current target doesn't have an ETM configured");
+               command_print(CMD_CTX, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
        if (strcmp(arm->etm->capture_driver->name, "oocd_trace") != 0)
        {
-               command_print(cmd_ctx, "current target's ETM capture driver isn't 'oocd_trace'");
+               command_print(CMD_CTX, "current target's ETM capture driver isn't 'oocd_trace'");
                return ERROR_FAIL;
        }
 
@@ -359,39 +359,39 @@ COMMAND_HANDLER(handle_oocd_trace_status_command)
        oocd_trace_read_reg(oocd_trace, OOCD_TRACE_STATUS, &status);
 
        if (status & 0x8)
-               command_print(cmd_ctx, "trace clock locked");
+               command_print(CMD_CTX, "trace clock locked");
        else
-               command_print(cmd_ctx, "no trace clock");
+               command_print(CMD_CTX, "no trace clock");
 
        return ERROR_OK;
 }
 
 COMMAND_HANDLER(handle_oocd_trace_resync_command)
 {
-       target_t *target;
+       struct target *target;
        struct arm *arm;
        struct oocd_trace *oocd_trace;
        size_t bytes_written;
        uint8_t cmd_array[1];
 
-       target = get_current_target(cmd_ctx);
+       target = get_current_target(CMD_CTX);
 
        arm = target_to_arm(target);
        if (!is_arm(arm))
        {
-               command_print(cmd_ctx, "current target isn't an ARM");
+               command_print(CMD_CTX, "current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        if (!arm->etm)
        {
-               command_print(cmd_ctx, "current target doesn't have an ETM configured");
+               command_print(CMD_CTX, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
        if (strcmp(arm->etm->capture_driver->name, "oocd_trace") != 0)
        {
-               command_print(cmd_ctx, "current target's ETM capture driver isn't 'oocd_trace'");
+               command_print(CMD_CTX, "current target's ETM capture driver isn't 'oocd_trace'");
                return ERROR_FAIL;
        }
 
@@ -401,22 +401,22 @@ COMMAND_HANDLER(handle_oocd_trace_resync_command)
 
        bytes_written = write(oocd_trace->tty_fd, cmd_array, 1);
 
-       command_print(cmd_ctx, "requesting traceclock resync");
+       command_print(CMD_CTX, "requesting traceclock resync");
        LOG_DEBUG("resyncing traceclk pll");
 
        return ERROR_OK;
 }
 
-int oocd_trace_register_commands(struct command_context_s *cmd_ctx)
+int oocd_trace_register_commands(struct command_context *cmd_ctx)
 {
-       command_t *oocd_trace_cmd;
+       struct command *oocd_trace_cmd;
 
-       oocd_trace_cmd = register_command(cmd_ctx, NULL, "oocd_trace", NULL, COMMAND_ANY, "OpenOCD + trace");
+       oocd_trace_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "oocd_trace", NULL, COMMAND_ANY, "OpenOCD + trace");
 
-       register_command(cmd_ctx, oocd_trace_cmd, "config", handle_oocd_trace_config_command, COMMAND_CONFIG, NULL);
+       COMMAND_REGISTER(cmd_ctx, oocd_trace_cmd, "config", handle_oocd_trace_config_command, COMMAND_CONFIG, NULL);
 
-       register_command(cmd_ctx, oocd_trace_cmd, "status", handle_oocd_trace_status_command, COMMAND_EXEC, "display OpenOCD + trace status");
-       register_command(cmd_ctx, oocd_trace_cmd, "resync", handle_oocd_trace_resync_command, COMMAND_EXEC, "resync OpenOCD + trace capture clock");
+       COMMAND_REGISTER(cmd_ctx, oocd_trace_cmd, "status", handle_oocd_trace_status_command, COMMAND_EXEC, "display OpenOCD + trace status");
+       COMMAND_REGISTER(cmd_ctx, oocd_trace_cmd, "resync", handle_oocd_trace_resync_command, COMMAND_EXEC, "resync OpenOCD + trace capture clock");
 
        return ERROR_OK;
 }