free(etm_ctx->trace_data);
}
- if ((etm_ctx->portmode & ETM_PORT_WIDTH_MASK) == ETM_PORT_4BIT)
+ if ((etm_ctx->control & ETM_PORT_WIDTH_MASK) == ETM_PORT_4BIT)
etm_ctx->trace_depth = num_frames * 3;
- else if ((etm_ctx->portmode & ETM_PORT_WIDTH_MASK) == ETM_PORT_8BIT)
+ else if ((etm_ctx->control & ETM_PORT_WIDTH_MASK) == ETM_PORT_8BIT)
etm_ctx->trace_depth = num_frames * 2;
else
etm_ctx->trace_depth = num_frames;
for (i = 0, j = 0; i < num_frames; i++)
{
- if ((etm_ctx->portmode & ETM_PORT_WIDTH_MASK) == ETM_PORT_4BIT)
+ if ((etm_ctx->control & ETM_PORT_WIDTH_MASK) == ETM_PORT_4BIT)
{
/* trace word j */
etm_ctx->trace_data[j].pipestat = trace_data[i] & 0x7;
j += 3;
}
- else if ((etm_ctx->portmode & ETM_PORT_WIDTH_MASK) == ETM_PORT_8BIT)
+ else if ((etm_ctx->control & ETM_PORT_WIDTH_MASK) == ETM_PORT_8BIT)
{
/* trace word j */
etm_ctx->trace_data[j].pipestat = trace_data[i] & 0x7;
uint32_t etb_ctrl_value = 0x1;
uint32_t trigger_count;
- if ((etm_ctx->portmode & ETM_PORT_MODE_MASK) == ETM_PORT_DEMUXED)
+ if ((etm_ctx->control & ETM_PORT_MODE_MASK) == ETM_PORT_DEMUXED)
{
- if ((etm_ctx->portmode & ETM_PORT_WIDTH_MASK) != ETM_PORT_8BIT)
+ if ((etm_ctx->control & ETM_PORT_WIDTH_MASK) != ETM_PORT_8BIT)
{
LOG_ERROR("ETB can't run in demultiplexed mode with a 4 or 16 bit port");
return ERROR_ETM_PORTMODE_NOT_SUPPORTED;
etb_ctrl_value |= 0x2;
}
- if ((etm_ctx->portmode & ETM_PORT_MODE_MASK) == ETM_PORT_MUXED) {
+ if ((etm_ctx->control & ETM_PORT_MODE_MASK) == ETM_PORT_MUXED) {
LOG_ERROR("ETB: can't run in multiplexed mode");
return ERROR_ETM_PORTMODE_NOT_SUPPORTED;
}
/* initialize some ETM control register settings */
etm_get_reg(etm_ctrl_reg);
- etm_ctrl_value = buf_get_u32(etm_ctrl_reg->value, 0, etm_ctrl_reg->size);
+ etm_ctrl_value = buf_get_u32(etm_ctrl_reg->value, 0, 32);
/* clear the ETM powerdown bit (0) */
- etm_ctrl_value &= ~0x1;
+ etm_ctrl_value &= ~ETM_CTRL_POWERDOWN;
/* configure port width (21,6:4), mode (13,17:16) and
* for older modules clocking (13)
& ~ETM_PORT_WIDTH_MASK
& ~ETM_PORT_MODE_MASK
& ~ETM_PORT_CLOCK_MASK)
- | etm_ctx->portmode;
+ | etm_ctx->control;
- buf_set_u32(etm_ctrl_reg->value, 0, etm_ctrl_reg->size, etm_ctrl_value);
+ buf_set_u32(etm_ctrl_reg->value, 0, 32, etm_ctrl_value);
etm_store_reg(etm_ctrl_reg);
if ((retval = jtag_execute_queue()) != ERROR_OK)
continue;
}
- if ((ctx->portmode & ETM_PORT_WIDTH_MASK) == ETM_PORT_16BIT)
+ /* FIXME there are more port widths than these... */
+ if ((ctx->control & ETM_PORT_WIDTH_MASK) == ETM_PORT_16BIT)
{
if (ctx->data_half == 0)
{
ctx->data_index++;
}
}
- else if ((ctx->portmode & ETM_PORT_WIDTH_MASK) == ETM_PORT_8BIT)
+ else if ((ctx->control & ETM_PORT_WIDTH_MASK) == ETM_PORT_8BIT)
{
*packet = ctx->trace_data[ctx->data_index].packet & 0xff;
ctx->data_index++;
}
static COMMAND_HELPER(handle_etm_tracemode_command_update,
- etmv1_tracemode_t *mode)
+ uint32_t *mode)
{
- etmv1_tracemode_t tracemode;
+ uint32_t tracemode;
/* what parts of data access are traced? */
if (strcmp(CMD_ARGV[0], "none") == 0)
bool etmv1_branch_output;
COMMAND_PARSE_ENABLE(CMD_ARGV[3], etmv1_branch_output);
+ if (etmv1_branch_output)
tracemode |= ETMV1_BRANCH_OUTPUT;
/* IGNORED:
return ERROR_FAIL;
}
- etmv1_tracemode_t tracemode = etm->tracemode;
+ uint32_t tracemode = etm->tracemode;
switch (CMD_ARGC)
{
{
struct target *target;
struct arm *arm;
- etm_portmode_t portmode = 0x0;
+ uint32_t portmode = 0x0;
struct etm_context *etm_ctx;
int i;
etm_ctx->target = target;
etm_ctx->trace_data = NULL;
- etm_ctx->portmode = portmode;
+ etm_ctx->control = portmode;
etm_ctx->core_state = ARM_STATE_ARM;
arm->etm = etm_ctx;
}
fileio_write_u32(&file, etm_ctx->capture_status);
- fileio_write_u32(&file, etm_ctx->portmode);
+ fileio_write_u32(&file, etm_ctx->control);
fileio_write_u32(&file, etm_ctx->tracemode);
fileio_write_u32(&file, etm_ctx->trace_depth);
{
uint32_t tmp;
fileio_read_u32(&file, &tmp); etm_ctx->capture_status = tmp;
- fileio_read_u32(&file, &tmp); etm_ctx->portmode = tmp;
+ fileio_read_u32(&file, &tmp); etm_ctx->control = tmp;
fileio_read_u32(&file, &tmp); etm_ctx->tracemode = tmp;
fileio_read_u32(&file, &etm_ctx->trace_depth);
}
struct arm_jtag *jtag_info;
};
-typedef enum
+/* Subset of ETM_CTRL bit assignments. Many of these
+ * control the configuration of trace output, which
+ * hooks up either to ETB or to an external device.
+ *
+ * NOTE that these have evolved since the ~v1.3 defns ...
+ */
+enum
{
- /* Port width */
+ ETM_CTRL_POWERDOWN = (1 << 0),
+ ETM_CTRL_MONITOR_CPRT = (1 << 1),
+
+ // bits 3:2 == trace type (ETMV1_TRACE_* << 2)
+
+ /* Port width (bits 21 and 6:4) */
ETM_PORT_4BIT = 0x00,
ETM_PORT_8BIT = 0x10,
ETM_PORT_16BIT = 0x20,
ETM_PORT_1BIT = 0x00 | (1 << 21),
ETM_PORT_2BIT = 0x10 | (1 << 21),
ETM_PORT_WIDTH_MASK = 0x70 | (1 << 21),
- /* Port modes */
- ETM_PORT_NORMAL = 0x00000,
- ETM_PORT_MUXED = 0x10000,
- ETM_PORT_DEMUXED = 0x20000,
- ETM_PORT_MODE_MASK = 0x30000,
- /* Clocking modes */
- ETM_PORT_FULL_CLOCK = 0x0000,
- ETM_PORT_HALF_CLOCK = 0x1000,
- ETM_PORT_CLOCK_MASK = 0x1000,
-} etm_portmode_t;
-typedef enum
+ ETM_CTRL_FIFOFULL_STALL = (1 << 7),
+ ETM_CTRL_BRANCH_OUTPUT = (1 << 8),
+ ETM_CTRL_DBGRQ = (1 << 9),
+ ETM_CTRL_ETM_PROG = (1 << 10),
+ ETM_CTRL_ETMEN = (1 << 11),
+ ETM_CTRL_CYCLE_ACCURATE = (1 << 12),
+
+ /* Clocking modes -- up to v2.1, bit 13 */
+ ETM_PORT_FULL_CLOCK = (0 << 13),
+ ETM_PORT_HALF_CLOCK = (1 << 13),
+ ETM_PORT_CLOCK_MASK = (1 << 13),
+
+ // bits 15:14 == context ID size used in tracing
+ // ETMV1_CONTEXTID_* << 8
+
+ /* Port modes -- bits 17:16, tied to clocking mode */
+ ETM_PORT_NORMAL = (0 << 16),
+ ETM_PORT_MUXED = (1 << 16),
+ ETM_PORT_DEMUXED = (2 << 16),
+ ETM_PORT_MODE_MASK = (3 << 16),
+
+ // bits 31:18 defined in v3.0 and later (e.g. ARM11+)
+};
+
+enum
{
/* Data trace */
ETMV1_TRACE_NONE = 0x00,
/* Misc */
ETMV1_CYCLE_ACCURATE = 0x100,
ETMV1_BRANCH_OUTPUT = 0x200
-} etmv1_tracemode_t;
+};
/* forward-declare ETM context */
struct etm_context;
trace_status_t capture_status; /* current state of capture run */
struct etmv1_trace_data *trace_data; /* trace data */
uint32_t trace_depth; /* number of cycles to be analyzed, 0 if no data available */
- etm_portmode_t portmode; /* normal, multiplexed or demultiplexed */
- etmv1_tracemode_t tracemode; /* type of info trace contains */
+ uint32_t control; /* shadow of ETM_CTRL */
+ uint32_t tracemode; /* type of info trace contains */
int /*arm_state*/ core_state; /* current core state */
struct image *image; /* source for target opcodes */
uint32_t pipe_index; /* current trace cycle */