command_handler: change 'args' to CMD_ARGV
[openocd.git] / src / target / etm.c
index 936c9e60f8e20692f1116927b99647997b64b4d9..72e8b3d21fe422b0f7b58da5e8863db8f36fe91f 100644 (file)
@@ -22,6 +22,7 @@
 #endif
 
 #include "armv4_5.h"
+#include "etm.h"
 #include "etb.h"
 #include "image.h"
 #include "arm_disassembler.h"
@@ -213,8 +214,6 @@ static const struct etm_reg_info etm_outputs[] = {
        { 0x6f, 32, RO, 0x20, "ETM_contextid_comparator_mask", }
 #endif
 
-static int etm_reg_arch_type = -1;
-
 static int etm_get_reg(struct reg *reg);
 static int etm_read_reg_w_check(struct reg *reg,
                uint8_t* check_value, uint8_t* check_mask);
@@ -224,6 +223,10 @@ static int etm_write_reg(struct reg *reg, uint32_t value);
 
 static struct command *etm_cmd;
 
+static const struct reg_arch_type etm_scan6_type = {
+       .get = etm_get_reg,
+       .set = etm_set_reg_w_exec,
+};
 
 /* Look up register by ID ... most ETM instances only
  * support a subset of the possible registers.
@@ -268,7 +271,7 @@ static void etm_reg_add(unsigned bcd_vers, struct arm_jtag *jtag_info,
                reg->size = r->size;
                reg->value = &ereg->value;
                reg->arch_info = ereg;
-               reg->arch_type = etm_reg_arch_type;
+               reg->type = &etm_scan6_type;
                reg++;
                cache->num_regs++;
 
@@ -286,11 +289,6 @@ struct reg_cache *etm_build_reg_cache(struct target *target,
        struct etm_reg *arch_info = NULL;
        unsigned bcd_vers, config;
 
-       /* register a register arch-type for etm registers only once */
-       if (etm_reg_arch_type == -1)
-               etm_reg_arch_type = register_reg_arch_type(etm_get_reg,
-                               etm_set_reg_w_exec);
-
        /* the actual registers are kept in two arrays */
        reg_list = calloc(128, sizeof(struct reg));
        arch_info = calloc(128, sizeof(struct etm_reg));
@@ -639,7 +637,7 @@ static int etm_read_instruction(struct etm_context *ctx, struct arm_instruction
 {
        int i;
        int section = -1;
-       uint32_t size_read;
+       size_t size_read;
        uint32_t opcode;
        int retval;
 
@@ -1181,22 +1179,22 @@ static COMMAND_HELPER(handle_etm_tracemode_command_update,
        etmv1_tracemode_t tracemode;
 
        /* what parts of data access are traced? */
-       if (strcmp(args[0], "none") == 0)
+       if (strcmp(CMD_ARGV[0], "none") == 0)
                tracemode = ETMV1_TRACE_NONE;
-       else if (strcmp(args[0], "data") == 0)
+       else if (strcmp(CMD_ARGV[0], "data") == 0)
                tracemode = ETMV1_TRACE_DATA;
-       else if (strcmp(args[0], "address") == 0)
+       else if (strcmp(CMD_ARGV[0], "address") == 0)
                tracemode = ETMV1_TRACE_ADDR;
-       else if (strcmp(args[0], "all") == 0)
+       else if (strcmp(CMD_ARGV[0], "all") == 0)
                tracemode = ETMV1_TRACE_DATA | ETMV1_TRACE_ADDR;
        else
        {
-               command_print(cmd_ctx, "invalid option '%s'", args[0]);
+               command_print(cmd_ctx, "invalid option '%s'", CMD_ARGV[0]);
                return ERROR_INVALID_ARGUMENTS;
        }
 
        uint8_t context_id;
-       COMMAND_PARSE_NUMBER(u8, args[1], context_id);
+       COMMAND_PARSE_NUMBER(u8, CMD_ARGV[1], context_id);
        switch (context_id)
        {
        case 0:
@@ -1212,27 +1210,27 @@ static COMMAND_HELPER(handle_etm_tracemode_command_update,
                tracemode |= ETMV1_CONTEXTID_32;
                break;
        default:
-               command_print(cmd_ctx, "invalid option '%s'", args[1]);
+               command_print(cmd_ctx, "invalid option '%s'", CMD_ARGV[1]);
                return ERROR_INVALID_ARGUMENTS;
        }
 
-       if (strcmp(args[2], "enable") == 0)
+       if (strcmp(CMD_ARGV[2], "enable") == 0)
                tracemode |= ETMV1_CYCLE_ACCURATE;
-       else if (strcmp(args[2], "disable") == 0)
+       else if (strcmp(CMD_ARGV[2], "disable") == 0)
                tracemode |= 0;
        else
        {
-               command_print(cmd_ctx, "invalid option '%s'", args[2]);
+               command_print(cmd_ctx, "invalid option '%s'", CMD_ARGV[2]);
                return ERROR_INVALID_ARGUMENTS;
        }
 
-       if (strcmp(args[3], "enable") == 0)
+       if (strcmp(CMD_ARGV[3], "enable") == 0)
                tracemode |= ETMV1_BRANCH_OUTPUT;
-       else if (strcmp(args[3], "disable") == 0)
+       else if (strcmp(CMD_ARGV[3], "disable") == 0)
                tracemode |= 0;
        else
        {
-               command_print(cmd_ctx, "invalid option '%s'", args[3]);
+               command_print(cmd_ctx, "invalid option '%s'", CMD_ARGV[3]);
                return ERROR_INVALID_ARGUMENTS;
        }
 
@@ -1265,7 +1263,7 @@ COMMAND_HANDLER(handle_etm_tracemode_command)
 
        etmv1_tracemode_t tracemode = etm->tracemode;
 
-       switch (argc)
+       switch (CMD_ARGC)
        {
        case 0:
                break;
@@ -1376,13 +1374,13 @@ COMMAND_HANDLER(handle_etm_config_command)
        struct etm_context *etm_ctx;
        int i;
 
-       if (argc != 5)
+       if (CMD_ARGC != 5)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
-       target = get_target(args[0]);
+       target = get_target(CMD_ARGV[0]);
        if (!target)
        {
-               LOG_ERROR("target '%s' not defined", args[0]);
+               LOG_ERROR("target '%s' not defined", CMD_ARGV[0]);
                return ERROR_FAIL;
        }
 
@@ -1406,7 +1404,7 @@ COMMAND_HANDLER(handle_etm_config_command)
         *    "normal full" ...
         */
        uint8_t port_width;
-       COMMAND_PARSE_NUMBER(u8, args[1], port_width);
+       COMMAND_PARSE_NUMBER(u8, CMD_ARGV[1], port_width);
        switch (port_width)
        {
                /* before ETMv3.0 */
@@ -1440,39 +1438,39 @@ COMMAND_HANDLER(handle_etm_config_command)
                        break;
                default:
                        command_print(cmd_ctx,
-                               "unsupported ETM port width '%s'", args[1]);
+                               "unsupported ETM port width '%s'", CMD_ARGV[1]);
                        return ERROR_FAIL;
        }
 
-       if (strcmp("normal", args[2]) == 0)
+       if (strcmp("normal", CMD_ARGV[2]) == 0)
        {
                portmode |= ETM_PORT_NORMAL;
        }
-       else if (strcmp("multiplexed", args[2]) == 0)
+       else if (strcmp("multiplexed", CMD_ARGV[2]) == 0)
        {
                portmode |= ETM_PORT_MUXED;
        }
-       else if (strcmp("demultiplexed", args[2]) == 0)
+       else if (strcmp("demultiplexed", CMD_ARGV[2]) == 0)
        {
                portmode |= ETM_PORT_DEMUXED;
        }
        else
        {
-               command_print(cmd_ctx, "unsupported ETM port mode '%s', must be 'normal', 'multiplexed' or 'demultiplexed'", args[2]);
+               command_print(cmd_ctx, "unsupported ETM port mode '%s', must be 'normal', 'multiplexed' or 'demultiplexed'", CMD_ARGV[2]);
                return ERROR_FAIL;
        }
 
-       if (strcmp("half", args[3]) == 0)
+       if (strcmp("half", CMD_ARGV[3]) == 0)
        {
                portmode |= ETM_PORT_HALF_CLOCK;
        }
-       else if (strcmp("full", args[3]) == 0)
+       else if (strcmp("full", CMD_ARGV[3]) == 0)
        {
                portmode |= ETM_PORT_FULL_CLOCK;
        }
        else
        {
-               command_print(cmd_ctx, "unsupported ETM port clocking '%s', must be 'full' or 'half'", args[3]);
+               command_print(cmd_ctx, "unsupported ETM port clocking '%s', must be 'full' or 'half'", CMD_ARGV[3]);
                return ERROR_FAIL;
        }
 
@@ -1484,7 +1482,7 @@ COMMAND_HANDLER(handle_etm_config_command)
 
        for (i = 0; etm_capture_drivers[i]; i++)
        {
-               if (strcmp(args[4], etm_capture_drivers[i]->name) == 0)
+               if (strcmp(CMD_ARGV[4], etm_capture_drivers[i]->name) == 0)
                {
                        int retval;
                        if ((retval = etm_capture_drivers[i]->register_commands(cmd_ctx)) != ERROR_OK)
@@ -1503,7 +1501,7 @@ COMMAND_HANDLER(handle_etm_config_command)
        {
                /* no supported capture driver found, don't register an ETM */
                free(etm_ctx);
-               LOG_ERROR("trace capture driver '%s' not found", args[4]);
+               LOG_ERROR("trace capture driver '%s' not found", CMD_ARGV[4]);
                return ERROR_FAIL;
        }
 
@@ -1732,7 +1730,7 @@ COMMAND_HANDLER(handle_etm_image_command)
        struct arm *arm;
        struct etm_context *etm_ctx;
 
-       if (argc < 1)
+       if (CMD_ARGC < 1)
        {
                command_print(cmd_ctx, "usage: etm image <file> [base address] [type]");
                return ERROR_FAIL;
@@ -1765,17 +1763,17 @@ COMMAND_HANDLER(handle_etm_image_command)
        etm_ctx->image->start_address_set = 0;
 
        /* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
-       if (argc >= 2)
+       if (CMD_ARGC >= 2)
        {
                etm_ctx->image->base_address_set = 1;
-               COMMAND_PARSE_NUMBER(int, args[1], etm_ctx->image->base_address);
+               COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], etm_ctx->image->base_address);
        }
        else
        {
                etm_ctx->image->base_address_set = 0;
        }
 
-       if (image_open(etm_ctx->image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
+       if (image_open(etm_ctx->image, CMD_ARGV[0], (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK)
        {
                free(etm_ctx->image);
                etm_ctx->image = NULL;
@@ -1793,7 +1791,7 @@ COMMAND_HANDLER(handle_etm_dump_command)
        struct etm_context *etm_ctx;
        uint32_t i;
 
-       if (argc != 1)
+       if (CMD_ARGC != 1)
        {
                command_print(cmd_ctx, "usage: etm dump <file>");
                return ERROR_FAIL;
@@ -1831,7 +1829,7 @@ COMMAND_HANDLER(handle_etm_dump_command)
        if (etm_ctx->trace_depth == 0)
                etm_ctx->capture_driver->read_trace(etm_ctx);
 
-       if (fileio_open(&file, args[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK)
+       if (fileio_open(&file, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK)
        {
                return ERROR_FAIL;
        }
@@ -1861,7 +1859,7 @@ COMMAND_HANDLER(handle_etm_load_command)
        struct etm_context *etm_ctx;
        uint32_t i;
 
-       if (argc != 1)
+       if (CMD_ARGC != 1)
        {
                command_print(cmd_ctx, "usage: etm load <file>");
                return ERROR_FAIL;
@@ -1888,7 +1886,7 @@ COMMAND_HANDLER(handle_etm_load_command)
                return ERROR_FAIL;
        }
 
-       if (fileio_open(&file, args[0], FILEIO_READ, FILEIO_BINARY) != ERROR_OK)
+       if (fileio_open(&file, CMD_ARGV[0], FILEIO_READ, FILEIO_BINARY) != ERROR_OK)
        {
                return ERROR_FAIL;
        }
@@ -1958,10 +1956,10 @@ COMMAND_HANDLER(handle_etm_trigger_percent_command)
                return ERROR_FAIL;
        }
 
-       if (argc > 0)
+       if (CMD_ARGC > 0)
        {
                uint32_t new_value;
-               COMMAND_PARSE_NUMBER(u32, args[0], new_value);
+               COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], new_value);
 
                if ((new_value < 2) || (new_value > 100))
                {

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)