summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/target/etb.c93
-rw-r--r--src/target/etm.c43
2 files changed, 82 insertions, 54 deletions
diff --git a/src/target/etb.c b/src/target/etb.c
index 40bb34a1..5b81895d 100644
--- a/src/target/etb.c
+++ b/src/target/etb.c
@@ -110,13 +110,13 @@ static int etb_get_reg(reg_t *reg)
if ((retval = etb_read_reg(reg)) != ERROR_OK)
{
- LOG_ERROR("BUG: error scheduling etm register read");
+ LOG_ERROR("BUG: error scheduling ETB register read");
return retval;
}
if ((retval = jtag_execute_queue()) != ERROR_OK)
{
- LOG_ERROR("register read failed");
+ LOG_ERROR("ETB register read failed");
return retval;
}
@@ -288,7 +288,7 @@ static int etb_set_reg(reg_t *reg, uint32_t value)
if ((retval = etb_write_reg(reg, value)) != ERROR_OK)
{
- LOG_ERROR("BUG: error scheduling etm register write");
+ LOG_ERROR("BUG: error scheduling ETB register write");
return retval;
}
@@ -307,7 +307,7 @@ static int etb_set_reg_w_exec(reg_t *reg, uint8_t *buf)
if ((retval = jtag_execute_queue()) != ERROR_OK)
{
- LOG_ERROR("register write failed");
+ LOG_ERROR("ETB: register write failed");
return retval;
}
return ERROR_OK;
@@ -378,20 +378,20 @@ static int handle_etb_config_command(struct command_context_s *cmd_ctx, char *cm
if (!target)
{
- LOG_ERROR("target '%s' not defined", args[0]);
+ LOG_ERROR("ETB: target '%s' not defined", args[0]);
return ERROR_FAIL;
}
if (arm7_9_get_arch_pointers(target, &armv4_5, &arm7_9) != ERROR_OK)
{
- command_print(cmd_ctx, "current target isn't an ARM7/ARM9 target");
+ command_print(cmd_ctx, "ETB: current target isn't an ARM7/ARM9 target");
return ERROR_FAIL;
}
tap = jtag_tap_by_string(args[1]);
if (tap == NULL)
{
- command_print(cmd_ctx, "Tap: %s does not exist", args[1]);
+ command_print(cmd_ctx, "ETB: TAP %s does not exist", args[1]);
return ERROR_FAIL;
}
@@ -409,7 +409,7 @@ static int handle_etb_config_command(struct command_context_s *cmd_ctx, char *cm
}
else
{
- LOG_ERROR("target has no ETM defined, ETB left unconfigured");
+ LOG_ERROR("ETM: target has no ETM defined, ETB left unconfigured");
return ERROR_FAIL;
}
@@ -436,56 +436,53 @@ static int etb_init(etm_context_t *etm_ctx)
static trace_status_t etb_status(etm_context_t *etm_ctx)
{
etb_t *etb = etm_ctx->capture_driver_priv;
+ reg_t *control = &etb->reg_cache->reg_list[ETB_CTRL];
+ reg_t *status = &etb->reg_cache->reg_list[ETB_STATUS];
+ trace_status_t retval = 0;
+ int etb_timeout = 100;
etb->etm_ctx = etm_ctx;
- /* if tracing is currently idle, return this information */
- if (etm_ctx->capture_status == TRACE_IDLE)
- {
- return etm_ctx->capture_status;
- }
- else if (etm_ctx->capture_status & TRACE_RUNNING)
- {
- reg_t *etb_status_reg = &etb->reg_cache->reg_list[ETB_STATUS];
- int etb_timeout = 100;
+ /* read control and status registers */
+ etb_read_reg(control);
+ etb_read_reg(status);
+ jtag_execute_queue();
- /* trace is running, check the ETB status flags */
- etb_get_reg(etb_status_reg);
+ /* See if it's (still) active */
+ retval = buf_get_u32(control->value, 0, 1) ? TRACE_RUNNING : TRACE_IDLE;
- /* check Full bit to identify an overflow */
- if (buf_get_u32(etb_status_reg->value, 0, 1) == 1)
- etm_ctx->capture_status |= TRACE_OVERFLOWED;
+ /* check Full bit to identify wraparound/overflow */
+ if (buf_get_u32(status->value, 0, 1) == 1)
+ retval |= TRACE_OVERFLOWED;
- /* check Triggered bit to identify trigger condition */
- if (buf_get_u32(etb_status_reg->value, 1, 1) == 1)
- etm_ctx->capture_status |= TRACE_TRIGGERED;
+ /* check Triggered bit to identify trigger condition */
+ if (buf_get_u32(status->value, 1, 1) == 1)
+ retval |= TRACE_TRIGGERED;
- /* check AcqComp to identify trace completion */
- if (buf_get_u32(etb_status_reg->value, 2, 1) == 1)
- {
- while (etb_timeout-- && (buf_get_u32(etb_status_reg->value, 3, 1) == 0))
- {
- /* wait for data formatter idle */
- etb_get_reg(etb_status_reg);
- }
+ /* check AcqComp to see if trigger counter dropped to zero */
+ if (buf_get_u32(status->value, 2, 1) == 1) {
+ /* wait for DFEmpty */
+ while (etb_timeout-- && buf_get_u32(status->value, 3, 1) == 0)
+ etb_get_reg(status);
- if (etb_timeout == 0)
- {
- LOG_ERROR("AcqComp set but DFEmpty won't go high, ETB status: 0x%" PRIx32 "",
- buf_get_u32(etb_status_reg->value, 0, etb_status_reg->size));
- }
+ if (etb_timeout == 0)
+ LOG_ERROR("ETB: DFEmpty won't go high, status 0x%02x",
+ (unsigned) buf_get_u32(status->value, 0, 4));
- if (!(etm_ctx->capture_status && TRACE_TRIGGERED))
- {
- LOG_ERROR("trace completed, but no trigger condition detected");
- }
+ if (!(etm_ctx->capture_status & TRACE_TRIGGERED))
+ LOG_WARNING("ETB: trace complete without triggering?");
- etm_ctx->capture_status &= ~TRACE_RUNNING;
- etm_ctx->capture_status |= TRACE_COMPLETED;
- }
+ retval |= TRACE_COMPLETED;
}
- return etm_ctx->capture_status;
+ /* NOTE: using a trigger is optional; and at least ETB11 has a mode
+ * where it can ignore the trigger counter.
+ */
+
+ /* update recorded state */
+ etm_ctx->capture_status = retval;
+
+ return retval;
}
static int etb_read_trace(etm_context_t *etm_ctx)
@@ -654,8 +651,10 @@ static int etb_start_capture(etm_context_t *etm_ctx)
etb_ctrl_value |= 0x2;
}
- if ((etm_ctx->portmode & ETM_PORT_MODE_MASK) == ETM_PORT_MUXED)
+ if ((etm_ctx->portmode & ETM_PORT_MODE_MASK) == ETM_PORT_MUXED) {
+ LOG_ERROR("ETB: can't run in multiplexed mode");
return ERROR_ETM_PORTMODE_NOT_SUPPORTED;
+ }
trigger_count = (etb->ram_depth * etm_ctx->trigger_percent) / 100;
diff --git a/src/target/etm.c b/src/target/etm.c
index cb18b21d..5a774f4d 100644
--- a/src/target/etm.c
+++ b/src/target/etm.c
@@ -1567,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);
@@ -1582,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));
}
}