-
- /* 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;
-
- /* trace is running, check the ETB status flags */
- etb_get_reg(etb_status_reg);
-
- /* 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 Triggered bit to identify trigger condition */
- if (buf_get_u32(etb_status_reg->value, 1, 1) == 1)
- etm_ctx->capture_status |= 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);
- }
-
- if (etb_timeout == 0)
- {
- LOG_ERROR("AcqComp set but DFEmpty won't go high, ETB status: 0x%x",
- buf_get_u32(etb_status_reg->value, 0, etb_status_reg->size));
- }
-
- if (!(etm_ctx->capture_status && TRACE_TRIGGERED))
- {
- LOG_ERROR("trace completed, but no trigger condition detected");
- }
-
- etm_ctx->capture_status &= ~TRACE_RUNNING;
- etm_ctx->capture_status |= TRACE_COMPLETED;
- }
+
+ /* read control and status registers */
+ etb_read_reg(control);
+ etb_read_reg(status);
+ jtag_execute_queue();
+
+ /* See if it's (still) active */
+ retval = buf_get_u32(control->value, 0, 1) ? TRACE_RUNNING : TRACE_IDLE;
+
+ /* 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(status->value, 1, 1) == 1)
+ retval |= TRACE_TRIGGERED;
+
+ /* 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("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_WARNING("ETB: trace complete without triggering?");
+
+ retval |= TRACE_COMPLETED;