printf format warning fixes
[openocd.git] / src / target / etm.c
index 91c73a232db44e7a73f68b06c6aa8a930be91195..34e2ca8a3c42c93563e13a6224ea71877f0c0a7a 100644 (file)
@@ -68,6 +68,7 @@ struct etm_reg_info {
 
 /*
  * Registers 0..0x7f are JTAG-addressable using scanchain 6.
+ * (Or on some processors, through coprocessor operations.)
  * Newer versions of ETM make some W/O registers R/W, and
  * provide definitions for some previously-unused bits.
  */
@@ -154,7 +155,7 @@ static const struct etm_reg_info etm_data_comp[] = {
 };
 
 static const struct etm_reg_info etm_counters[] = {
-#define COUNTER(i) \
+#define ETM_COUNTER(i) \
                { ETM_COUNTER_RELOAD_VALUE + (i), 16, WO, 0x10, \
                                "ETM_COUNTER_RELOAD_VALUE" #i, }, \
                { ETM_COUNTER_ENABLE + (i), 18, WO, 0x10, \
@@ -163,38 +164,38 @@ static const struct etm_reg_info etm_counters[] = {
                                "ETM_COUNTER_RELOAD_EVENT" #i, }, \
                { ETM_COUNTER_VALUE + (i), 16, RO, 0x10, \
                                "ETM_COUNTER_VALUE" #i, }
-       COUNTER(0),
-       COUNTER(1),
-       COUNTER(2),
-       COUNTER(3),
-#undef COUNTER
+       ETM_COUNTER(0),
+       ETM_COUNTER(1),
+       ETM_COUNTER(2),
+       ETM_COUNTER(3),
+#undef ETM_COUNTER
 };
 
 static const struct etm_reg_info etm_sequencer[] = {
-#define SEQ(i) \
+#define ETM_SEQ(i) \
                { ETM_SEQUENCER_EVENT + (i), 17, WO, 0x10, \
                                "ETM_SEQUENCER_EVENT" #i, }
-       SEQ(0),                         /* 1->2 */
-       SEQ(1),                         /* 2->1 */
-       SEQ(2),                         /* 2->3 */
-       SEQ(3),                         /* 3->1 */
-       SEQ(4),                         /* 3->2 */
-       SEQ(5),                         /* 1->3 */
-#undef SEQ
+       ETM_SEQ(0),                             /* 1->2 */
+       ETM_SEQ(1),                             /* 2->1 */
+       ETM_SEQ(2),                             /* 2->3 */
+       ETM_SEQ(3),                             /* 3->1 */
+       ETM_SEQ(4),                             /* 3->2 */
+       ETM_SEQ(5),                             /* 1->3 */
+#undef ETM_SEQ
        /* 0x66 reserved */
        { ETM_SEQUENCER_STATE,  2, RO, 0x10, "ETM_SEQUENCER_STATE", },
 };
 
 static const struct etm_reg_info etm_outputs[] = {
-#define OUT(i) \
+#define ETM_OUTPUT(i) \
                { ETM_EXTERNAL_OUTPUT + (i), 17, WO, 0x10, \
                                "ETM_EXTERNAL_OUTPUT" #i, }
 
-       OUT(0),
-       OUT(1),
-       OUT(2),
-       OUT(3),
-#undef OUT
+       ETM_OUTPUT(0),
+       ETM_OUTPUT(1),
+       ETM_OUTPUT(2),
+       ETM_OUTPUT(3),
+#undef ETM_OUTPUT
 };
 
 #if 0
@@ -1496,29 +1497,29 @@ static int handle_etm_info_command(struct command_context_s *cmd_ctx,
        command_print(cmd_ctx, "ETM v%d.%d",
                        etm->bcd_vers >> 4, etm->bcd_vers & 0xf);
        command_print(cmd_ctx, "pairs of address comparators: %i",
-                       (etm->config >> 0) & 0x0f);
+                       (int) (etm->config >> 0) & 0x0f);
        command_print(cmd_ctx, "data comparators: %i",
-                       (etm->config >> 4) & 0x0f);
+                       (int) (etm->config >> 4) & 0x0f);
        command_print(cmd_ctx, "memory map decoders: %i",
-                       (etm->config >> 8) & 0x1f);
+                       (int) (etm->config >> 8) & 0x1f);
        command_print(cmd_ctx, "number of counters: %i",
-                       (etm->config >> 13) & 0x07);
+                       (int) (etm->config >> 13) & 0x07);
        command_print(cmd_ctx, "sequencer %spresent",
-                       (etm->config & (1 << 16)) ? "" : "not ");
+                       (int) (etm->config & (1 << 16)) ? "" : "not ");
        command_print(cmd_ctx, "number of ext. inputs: %i",
-                       (etm->config >> 17) & 0x07);
+                       (int) (etm->config >> 17) & 0x07);
        command_print(cmd_ctx, "number of ext. outputs: %i",
-                       (etm->config >> 20) & 0x07);
+                       (int) (etm->config >> 20) & 0x07);
        command_print(cmd_ctx, "FIFO full %spresent",
-                       (etm->config & (1 << 23)) ? "" : "not ");
+                       (int) (etm->config & (1 << 23)) ? "" : "not ");
        if (etm->bcd_vers < 0x20)
                command_print(cmd_ctx, "protocol version: %i",
-                               (etm->config >> 28) & 0x07);
+                               (int) (etm->config >> 28) & 0x07);
        else {
                command_print(cmd_ctx, "trace start/stop %spresent",
                                (etm->config & (1 << 26)) ? "" : "not ");
                command_print(cmd_ctx, "number of context comparators: %i",
-                               (etm->config >> 24) & 0x03);
+                               (int) (etm->config >> 24) & 0x03);
        }
 
        /* SYS_CONFIG isn't present before ETMv1.2 */
@@ -1566,6 +1567,7 @@ static int handle_etm_status_command(struct command_context_s *cmd_ctx, char *cm
        target_t *target;
        armv4_5_common_t *armv4_5;
        arm7_9_common_t *arm7_9;
+       etm_context_t *etm;
        trace_status_t trace_status;
 
        target = get_current_target(cmd_ctx);
@@ -1581,28 +1583,56 @@ static int handle_etm_status_command(struct command_context_s *cmd_ctx, char *cm
                command_print(cmd_ctx, "current target doesn't have an ETM configured");
                return ERROR_OK;
        }
+       etm = arm7_9->etm_ctx;
 
-       trace_status = arm7_9->etm_ctx->capture_driver->status(arm7_9->etm_ctx);
+       /* ETM status */
+       if (etm->bcd_vers >= 0x11) {
+               reg_t *reg;
 
+               reg = etm_reg_lookup(etm, ETM_STATUS);
+               if (!reg)
+                       return ERROR_OK;
+               if (etm_get_reg(reg) == ERROR_OK) {
+                       unsigned s = buf_get_u32(reg->value, 0, reg->size);
+
+                       command_print(cmd_ctx, "etm: %s%s%s%s",
+                               /* bit(1) == progbit */
+                               (etm->bcd_vers >= 0x12)
+                                       ? ((s & (1 << 1))
+                                               ? "disabled" : "enabled")
+                                       : "?",
+                               ((s & (1 << 3)) && etm->bcd_vers >= 0x31)
+                                       ? " triggered" : "",
+                               ((s & (1 << 2)) && etm->bcd_vers >= 0x12)
+                                       ? " start/stop" : "",
+                               ((s & (1 << 0)) && etm->bcd_vers >= 0x11)
+                                       ? " untraced-overflow" : "");
+               } /* else ignore and try showing trace port status */
+       }
+
+       /* Trace Port Driver status */
+       trace_status = etm->capture_driver->status(etm);
        if (trace_status == TRACE_IDLE)
        {
-               command_print(cmd_ctx, "tracing is idle");
+               command_print(cmd_ctx, "%s: idle", etm->capture_driver->name);
        }
        else
        {
                static char *completed = " completed";
                static char *running = " is running";
-               static char *overflowed = ", trace overflowed";
-               static char *triggered = ", trace triggered";
+               static char *overflowed = ", overflowed";
+               static char *triggered = ", triggered";
 
-               command_print(cmd_ctx, "trace collection%s%s%s",
+               command_print(cmd_ctx, "%s: trace collection%s%s%s",
+                       etm->capture_driver->name,
                        (trace_status & TRACE_RUNNING) ? running : completed,
                        (trace_status & TRACE_OVERFLOWED) ? overflowed : "",
                        (trace_status & TRACE_TRIGGERED) ? triggered : "");
 
-               if (arm7_9->etm_ctx->trace_depth > 0)
+               if (etm->trace_depth > 0)
                {
-                       command_print(cmd_ctx, "%i frames of trace data read", (int)(arm7_9->etm_ctx->trace_depth));
+                       command_print(cmd_ctx, "%i frames of trace data read",
+                                       (int)(etm->trace_depth));
                }
        }
 

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)