diff options
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/etm.c | 172 |
1 files changed, 84 insertions, 88 deletions
diff --git a/src/target/etm.c b/src/target/etm.c index 0f5a96f6..8229bb07 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -1155,112 +1155,108 @@ static int etmv1_analyze_trace(etm_context_t *ctx, struct command_context_s *cmd return ERROR_OK; } -static int handle_etm_tracemode_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_etm_tracemode_command_update( + struct command_context_s *cmd_ctx, + char **args, etmv1_tracemode_t *mode) { - target_t *target; - armv4_5_common_t *armv4_5; - arm7_9_common_t *arm7_9; etmv1_tracemode_t tracemode; - target = get_current_target(cmd_ctx); - - if (arm7_9_get_arch_pointers(target, &armv4_5, &arm7_9) != ERROR_OK) + /* what parts of data access are traced? */ + if (strcmp(args[0], "none") == 0) + tracemode = ETMV1_TRACE_NONE; + else if (strcmp(args[0], "data") == 0) + tracemode = ETMV1_TRACE_DATA; + else if (strcmp(args[0], "address") == 0) + tracemode = ETMV1_TRACE_ADDR; + else if (strcmp(args[0], "all") == 0) + tracemode = ETMV1_TRACE_DATA | ETMV1_TRACE_ADDR; + else { - command_print(cmd_ctx, "current target isn't an ARM7/ARM9 target"); + command_print(cmd_ctx, "invalid option '%s'", args[0]); return ERROR_OK; } - if (!arm7_9->etm_ctx) - { - command_print(cmd_ctx, "current target doesn't have an ETM configured"); + uint8_t context_id; + COMMAND_PARSE_NUMBER(u8, args[1], context_id); + switch (context_id) + { + case 0: + tracemode |= ETMV1_CONTEXTID_NONE; + break; + case 8: + tracemode |= ETMV1_CONTEXTID_8; + break; + case 16: + tracemode |= ETMV1_CONTEXTID_16; + break; + case 32: + tracemode |= ETMV1_CONTEXTID_32; + break; + default: + command_print(cmd_ctx, "invalid option '%s'", args[1]); return ERROR_OK; } - tracemode = arm7_9->etm_ctx->tracemode; + if (strcmp(args[2], "enable") == 0) + tracemode |= ETMV1_CYCLE_ACCURATE; + else if (strcmp(args[2], "disable") == 0) + tracemode |= 0; + else + { + command_print(cmd_ctx, "invalid option '%s'", args[2]); + return ERROR_OK; + } - if (argc == 4) + if (strcmp(args[3], "enable") == 0) + tracemode |= ETMV1_BRANCH_OUTPUT; + else if (strcmp(args[3], "disable") == 0) + tracemode |= 0; + else { - /* what parts of data access are traced? */ - if (strcmp(args[0], "none") == 0) - { - tracemode = ETMV1_TRACE_NONE; - } - else if (strcmp(args[0], "data") == 0) - { - tracemode = ETMV1_TRACE_DATA; - } - else if (strcmp(args[0], "address") == 0) - { - tracemode = ETMV1_TRACE_ADDR; - } - else if (strcmp(args[0], "all") == 0) - { - tracemode = ETMV1_TRACE_DATA | ETMV1_TRACE_ADDR; - } - else - { - command_print(cmd_ctx, "invalid option '%s'", args[0]); - return ERROR_OK; - } + command_print(cmd_ctx, "invalid option '%s'", args[3]); + return ERROR_OK; + } - uint8_t context_id; - COMMAND_PARSE_NUMBER(u8, args[1], context_id); - switch (context_id) - { - case 0: - tracemode |= ETMV1_CONTEXTID_NONE; - break; - case 8: - tracemode |= ETMV1_CONTEXTID_8; - break; - case 16: - tracemode |= ETMV1_CONTEXTID_16; - break; - case 32: - tracemode |= ETMV1_CONTEXTID_32; - break; - default: - command_print(cmd_ctx, "invalid option '%s'", args[1]); - return ERROR_OK; - } + /* IGNORED: + * - CPRT tracing (coprocessor register transfers) + * - debug request (causes debug entry on trigger) + * - stall on FIFOFULL (preventing tracedata lossage) + */ + *mode = tracemode; - if (strcmp(args[2], "enable") == 0) - { - tracemode |= ETMV1_CYCLE_ACCURATE; - } - else if (strcmp(args[2], "disable") == 0) - { - tracemode |= 0; - } - else - { - command_print(cmd_ctx, "invalid option '%s'", args[2]); - return ERROR_OK; - } + return ERROR_OK; +} - if (strcmp(args[3], "enable") == 0) - { - tracemode |= ETMV1_BRANCH_OUTPUT; - } - else if (strcmp(args[3], "disable") == 0) - { - tracemode |= 0; - } - else - { - command_print(cmd_ctx, "invalid option '%s'", args[2]); - return ERROR_OK; - } +static int handle_etm_tracemode_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +{ + target_t *target = get_current_target(cmd_ctx); - /* IGNORED: - * - CPRT tracing (coprocessor register transfers) - * - debug request (causes debug entry on trigger) - * - stall on FIFOFULL (preventing tracedata lossage) - */ + armv4_5_common_t *armv4_5; + arm7_9_common_t *arm7_9; + 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"); + return ERROR_OK; } - else if (argc != 0) + + if (!arm7_9->etm_ctx) + { + command_print(cmd_ctx, "current target doesn't have an ETM configured"); + return ERROR_OK; + } + + etmv1_tracemode_t tracemode = arm7_9->etm_ctx->tracemode; + switch (argc) { - command_print(cmd_ctx, "usage: configure trace mode <none | data | address | all> <context id bits> <cycle accurate> <branch output>"); + case 0: + break; + case 4: + handle_etm_tracemode_command_update(cmd_ctx, args, &tracemode); + break; + default: + command_print(cmd_ctx, "usage: configure trace mode " + "<none | data | address | all> " + "<context id bits> <cycle accurate> <branch output>"); return ERROR_OK; } |