OpenOCD
etm_dummy.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2007 by Dominic Rath *
5  * Dominic.Rath@gmx.de *
6  ***************************************************************************/
7 
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11 
12 #include "arm.h"
13 #include "etm_dummy.h"
14 
15 COMMAND_HANDLER(handle_etm_dummy_config_command)
16 {
17  struct target *target;
18  struct arm *arm;
19 
21 
22  if (!target) {
23  LOG_ERROR("target '%s' not defined", CMD_ARGV[0]);
24  return ERROR_FAIL;
25  }
26 
28  if (!is_arm(arm)) {
29  command_print(CMD, "target '%s' isn't an ARM", CMD_ARGV[0]);
30  return ERROR_FAIL;
31  }
32 
33  if (arm->etm)
35  else {
36  LOG_ERROR("target has no ETM defined, ETM dummy left unconfigured");
37  return ERROR_FAIL;
38  }
39 
40  return ERROR_OK;
41 }
42 
44  {
45  .name = "config",
46  .handler = handle_etm_dummy_config_command,
47  .mode = COMMAND_CONFIG,
48  .usage = "target",
49  },
51 };
52 static const struct command_registration etm_dummy_command_handlers[] = {
53  {
54  .name = "etm_dummy",
55  .mode = COMMAND_ANY,
56  .help = "Dummy ETM capture driver command group",
58  .usage = "",
59  },
61 };
62 
63 static int etm_dummy_init(struct etm_context *etm_ctx)
64 {
65  return ERROR_OK;
66 }
67 
69 {
70  return TRACE_IDLE;
71 }
72 
73 static int etm_dummy_read_trace(struct etm_context *etm_ctx)
74 {
75  return ERROR_OK;
76 }
77 
78 static int etm_dummy_start_capture(struct etm_context *etm_ctx)
79 {
81 }
82 
83 static int etm_dummy_stop_capture(struct etm_context *etm_ctx)
84 {
85  return ERROR_OK;
86 }
87 
89  .name = "dummy",
90  .commands = etm_dummy_command_handlers,
91  .init = etm_dummy_init,
92  .status = etm_dummy_status,
93  .start_capture = etm_dummy_start_capture,
94  .stop_capture = etm_dummy_stop_capture,
95  .read_trace = etm_dummy_read_trace,
96 };
Holds the interface to ARM cores.
static bool is_arm(struct arm *arm)
Definition: arm.h:249
static struct arm * target_to_arm(struct target *target)
Convert target handle to generic ARM target state handle.
Definition: arm.h:243
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:473
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:140
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:155
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
#define ERROR_ETM_PORTMODE_NOT_SUPPORTED
Definition: etm.h:209
static const struct command_registration etm_dummy_config_command_handlers[]
Definition: etm_dummy.c:43
COMMAND_HANDLER(handle_etm_dummy_config_command)
Definition: etm_dummy.c:15
struct etm_capture_driver etm_dummy_capture_driver
Definition: etm_dummy.c:88
static trace_status_t etm_dummy_status(struct etm_context *etm_ctx)
Definition: etm_dummy.c:68
static int etm_dummy_start_capture(struct etm_context *etm_ctx)
Definition: etm_dummy.c:78
static int etm_dummy_read_trace(struct etm_context *etm_ctx)
Definition: etm_dummy.c:73
static const struct command_registration etm_dummy_command_handlers[]
Definition: etm_dummy.c:52
static int etm_dummy_init(struct etm_context *etm_ctx)
Definition: etm_dummy.c:63
static int etm_dummy_stop_capture(struct etm_context *etm_ctx)
Definition: etm_dummy.c:83
#define ERROR_FAIL
Definition: log.h:161
#define LOG_ERROR(expr ...)
Definition: log.h:123
#define ERROR_OK
Definition: log.h:155
struct target * target
Definition: rtt/rtt.c:26
Represents a generic ARM core, with standard application registers.
Definition: arm.h:167
struct etm_context * etm
Handle for the Embedded Trace Module, if one is present.
Definition: arm.h:208
const char * name
Definition: command.h:229
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:235
const char * name
Definition: etm.h:126
void * capture_driver_priv
Definition: etm.h:155
Definition: target.h:120
struct target * get_target(const char *id)
Definition: target.c:492
enum trace_status trace_status_t
@ TRACE_IDLE
Definition: trace.h:37
#define NULL
Definition: usb.h:16