OpenOCD
arm_cti.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2016 by Matthias Welwarsky *
5  * *
6  ***************************************************************************/
7 
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11 
12 #include <stdlib.h>
13 #include <stdint.h>
14 #include "target/arm_adi_v5.h"
15 #include "target/arm_cti.h"
16 #include "target/target.h"
17 #include "helper/time_support.h"
18 #include "helper/list.h"
19 #include "helper/command.h"
20 
21 struct arm_cti {
22  struct list_head lh;
23  char *name;
24  struct adiv5_mem_ap_spot spot;
25  struct adiv5_ap *ap;
26 };
27 
28 static LIST_HEAD(all_cti);
29 
30 const char *arm_cti_name(struct arm_cti *self)
31 {
32  return self->name;
33 }
34 
35 struct arm_cti *cti_instance_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
36 {
37  struct arm_cti *obj = NULL;
38  const char *name;
39  bool found = false;
40 
41  name = Jim_GetString(o, NULL);
42 
43  list_for_each_entry(obj, &all_cti, lh) {
44  if (!strcmp(name, obj->name)) {
45  found = true;
46  break;
47  }
48  }
49 
50  if (found)
51  return obj;
52  return NULL;
53 }
54 
55 static int arm_cti_mod_reg_bits(struct arm_cti *self, unsigned int reg, uint32_t mask, uint32_t value)
56 {
57  struct adiv5_ap *ap = self->ap;
58  uint32_t tmp;
59 
60  /* Read register */
61  int retval = mem_ap_read_atomic_u32(ap, self->spot.base + reg, &tmp);
62  if (retval != ERROR_OK)
63  return retval;
64 
65  /* clear bitfield */
66  tmp &= ~mask;
67  /* put new value */
68  tmp |= value & mask;
69 
70  /* write new value */
71  return mem_ap_write_atomic_u32(ap, self->spot.base + reg, tmp);
72 }
73 
74 int arm_cti_enable(struct arm_cti *self, bool enable)
75 {
76  uint32_t val = enable ? 1 : 0;
77 
78  return mem_ap_write_atomic_u32(self->ap, self->spot.base + CTI_CTR, val);
79 }
80 
81 int arm_cti_ack_events(struct arm_cti *self, uint32_t event)
82 {
83  struct adiv5_ap *ap = self->ap;
84  int retval;
85  uint32_t tmp;
86 
87  retval = mem_ap_write_atomic_u32(ap, self->spot.base + CTI_INACK, event);
88  if (retval == ERROR_OK) {
89  int64_t then = timeval_ms();
90  for (;;) {
91  retval = mem_ap_read_atomic_u32(ap, self->spot.base + CTI_TROUT_STATUS, &tmp);
92  if (retval != ERROR_OK)
93  break;
94  if ((tmp & event) == 0)
95  break;
96  if (timeval_ms() > then + 1000) {
97  LOG_ERROR("timeout waiting for target");
98  retval = ERROR_TARGET_TIMEOUT;
99  break;
100  }
101  }
102  }
103 
104  return retval;
105 }
106 
107 int arm_cti_gate_channel(struct arm_cti *self, uint32_t channel)
108 {
109  if (channel > 31)
111 
112  return arm_cti_mod_reg_bits(self, CTI_GATE, CTI_CHNL(channel), 0);
113 }
114 
115 int arm_cti_ungate_channel(struct arm_cti *self, uint32_t channel)
116 {
117  if (channel > 31)
119 
120  return arm_cti_mod_reg_bits(self, CTI_GATE, CTI_CHNL(channel), 0xFFFFFFFF);
121 }
122 
123 int arm_cti_write_reg(struct arm_cti *self, unsigned int reg, uint32_t value)
124 {
125  return mem_ap_write_atomic_u32(self->ap, self->spot.base + reg, value);
126 }
127 
128 int arm_cti_read_reg(struct arm_cti *self, unsigned int reg, uint32_t *p_value)
129 {
130  if (!p_value)
132 
133  return mem_ap_read_atomic_u32(self->ap, self->spot.base + reg, p_value);
134 }
135 
136 int arm_cti_pulse_channel(struct arm_cti *self, uint32_t channel)
137 {
138  if (channel > 31)
140 
141  return arm_cti_write_reg(self, CTI_APPPULSE, CTI_CHNL(channel));
142 }
143 
144 int arm_cti_set_channel(struct arm_cti *self, uint32_t channel)
145 {
146  if (channel > 31)
148 
149  return arm_cti_write_reg(self, CTI_APPSET, CTI_CHNL(channel));
150 }
151 
152 int arm_cti_clear_channel(struct arm_cti *self, uint32_t channel)
153 {
154  if (channel > 31)
156 
157  return arm_cti_write_reg(self, CTI_APPCLEAR, CTI_CHNL(channel));
158 }
159 
160 static const struct {
161  uint32_t offset;
162  const char *label;
163 } cti_names[] = {
164  { CTI_CTR, "CTR" },
165  { CTI_GATE, "GATE" },
166  { CTI_INEN0, "INEN0" },
167  { CTI_INEN1, "INEN1" },
168  { CTI_INEN2, "INEN2" },
169  { CTI_INEN3, "INEN3" },
170  { CTI_INEN4, "INEN4" },
171  { CTI_INEN5, "INEN5" },
172  { CTI_INEN6, "INEN6" },
173  { CTI_INEN7, "INEN7" },
174  { CTI_INEN8, "INEN8" },
175  { CTI_OUTEN0, "OUTEN0" },
176  { CTI_OUTEN1, "OUTEN1" },
177  { CTI_OUTEN2, "OUTEN2" },
178  { CTI_OUTEN3, "OUTEN3" },
179  { CTI_OUTEN4, "OUTEN4" },
180  { CTI_OUTEN5, "OUTEN5" },
181  { CTI_OUTEN6, "OUTEN6" },
182  { CTI_OUTEN7, "OUTEN7" },
183  { CTI_OUTEN8, "OUTEN8" },
184  { CTI_TRIN_STATUS, "TRIN" },
185  { CTI_TROUT_STATUS, "TROUT" },
186  { CTI_CHIN_STATUS, "CHIN" },
187  { CTI_CHOU_STATUS, "CHOUT" },
188  { CTI_APPSET, "APPSET" },
189  { CTI_APPCLEAR, "APPCLR" },
190  { CTI_APPPULSE, "APPPULSE" },
191  { CTI_INACK, "INACK" },
192  { CTI_DEVCTL, "DEVCTL" },
193 };
194 
195 static int cti_find_reg_offset(const char *name)
196 {
197  for (size_t i = 0; i < ARRAY_SIZE(cti_names); i++) {
198  if (!strcmp(name, cti_names[i].label))
199  return cti_names[i].offset;
200  }
201 
202  LOG_ERROR("unknown CTI register %s", name);
203  return -1;
204 }
205 
207 {
208  struct arm_cti *obj, *tmp;
209 
210  list_for_each_entry_safe(obj, tmp, &all_cti, lh) {
211  if (obj->ap)
212  dap_put_ap(obj->ap);
213  free(obj->name);
214  free(obj);
215  }
216 
217  return ERROR_OK;
218 }
219 
220 COMMAND_HANDLER(handle_cti_dump)
221 {
222  struct arm_cti *cti = CMD_DATA;
223  struct adiv5_ap *ap = cti->ap;
224  int retval = ERROR_OK;
225  uint32_t values[ARRAY_SIZE(cti_names)];
226 
227  for (size_t i = 0; (retval == ERROR_OK) && (i < ARRAY_SIZE(cti_names)); i++)
228  retval = mem_ap_read_u32(ap,
229  cti->spot.base + cti_names[i].offset, &values[i]);
230 
231  if (retval == ERROR_OK)
232  retval = dap_run(ap->dap);
233 
234  if (retval != ERROR_OK)
235  return JIM_ERR;
236 
237  for (size_t i = 0; i < ARRAY_SIZE(cti_names); i++)
238  command_print(CMD, "%8.8s (0x%04"PRIx32") 0x%08"PRIx32,
239  cti_names[i].label, cti_names[i].offset, values[i]);
240 
241  return JIM_OK;
242 }
243 
244 COMMAND_HANDLER(handle_cti_enable)
245 {
246  struct arm_cti *cti = CMD_DATA;
247  bool on_off;
248 
249  if (CMD_ARGC != 1)
251 
252  COMMAND_PARSE_ON_OFF(CMD_ARGV[0], on_off);
253 
254  return arm_cti_enable(cti, on_off);
255 }
256 
257 COMMAND_HANDLER(handle_cti_testmode)
258 {
259  struct arm_cti *cti = CMD_DATA;
260  bool on_off;
261 
262  if (CMD_ARGC != 1)
264 
265  COMMAND_PARSE_ON_OFF(CMD_ARGV[0], on_off);
266 
267  return arm_cti_write_reg(cti, 0xf00, on_off ? 0x1 : 0x0);
268 }
269 
270 COMMAND_HANDLER(handle_cti_write)
271 {
272  struct arm_cti *cti = CMD_DATA;
273  int offset;
274  uint32_t value;
275 
276  if (CMD_ARGC != 2)
278 
280  if (offset < 0)
281  return ERROR_FAIL;
282 
283  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value);
284 
285  return arm_cti_write_reg(cti, offset, value);
286 }
287 
288 COMMAND_HANDLER(handle_cti_read)
289 {
290  struct arm_cti *cti = CMD_DATA;
291  int offset;
292  int retval;
293  uint32_t value;
294 
295  if (CMD_ARGC != 1)
297 
299  if (offset < 0)
300  return ERROR_FAIL;
301 
302  retval = arm_cti_read_reg(cti, offset, &value);
303  if (retval != ERROR_OK)
304  return retval;
305 
306  command_print(CMD, "0x%08"PRIx32, value);
307 
308  return ERROR_OK;
309 }
310 
311 COMMAND_HANDLER(handle_cti_ack)
312 {
313  struct arm_cti *cti = CMD_DATA;
314  uint32_t event;
315 
316  if (CMD_ARGC != 1)
318 
319  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], event);
320 
321  int retval = arm_cti_ack_events(cti, 1 << event);
322 
323  if (retval != ERROR_OK)
324  return retval;
325 
326  return ERROR_OK;
327 }
328 
329 COMMAND_HANDLER(handle_cti_channel)
330 {
331  struct arm_cti *cti = CMD_DATA;
332  int retval = ERROR_OK;
333  uint32_t ch_num;
334 
335  if (CMD_ARGC != 2)
337 
338  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], ch_num);
339 
340  if (!strcmp(CMD_ARGV[1], "gate"))
341  retval = arm_cti_gate_channel(cti, ch_num);
342  else if (!strcmp(CMD_ARGV[1], "ungate"))
343  retval = arm_cti_ungate_channel(cti, ch_num);
344  else if (!strcmp(CMD_ARGV[1], "pulse"))
345  retval = arm_cti_pulse_channel(cti, ch_num);
346  else if (!strcmp(CMD_ARGV[1], "set"))
347  retval = arm_cti_set_channel(cti, ch_num);
348  else if (!strcmp(CMD_ARGV[1], "clear"))
349  retval = arm_cti_clear_channel(cti, ch_num);
350  else {
351  command_print(CMD, "Possible channel operations: gate|ungate|set|clear|pulse");
353  }
354 
355  if (retval != ERROR_OK)
356  return retval;
357 
358  return ERROR_OK;
359 }
360 
361 static const struct command_registration cti_instance_command_handlers[] = {
362  {
363  .name = "dump",
364  .mode = COMMAND_EXEC,
365  .handler = handle_cti_dump,
366  .help = "dump CTI registers",
367  .usage = "",
368  },
369  {
370  .name = "enable",
371  .mode = COMMAND_EXEC,
372  .handler = handle_cti_enable,
373  .help = "enable or disable the CTI",
374  .usage = "'on'|'off'",
375  },
376  {
377  .name = "testmode",
378  .mode = COMMAND_EXEC,
379  .handler = handle_cti_testmode,
380  .help = "enable or disable integration test mode",
381  .usage = "'on'|'off'",
382  },
383  {
384  .name = "write",
385  .mode = COMMAND_EXEC,
386  .handler = handle_cti_write,
387  .help = "write to a CTI register",
388  .usage = "register_name value",
389  },
390  {
391  .name = "read",
392  .mode = COMMAND_EXEC,
393  .handler = handle_cti_read,
394  .help = "read a CTI register",
395  .usage = "register_name",
396  },
397  {
398  .name = "ack",
399  .mode = COMMAND_EXEC,
400  .handler = handle_cti_ack,
401  .help = "acknowledge a CTI event",
402  .usage = "event",
403  },
404  {
405  .name = "channel",
406  .mode = COMMAND_EXEC,
407  .handler = handle_cti_channel,
408  .help = "do an operation on one CTI channel, possible operations: "
409  "gate, ungate, set, clear and pulse",
410  .usage = "channel_number operation",
411  },
413 };
414 
415 static int cti_configure(struct jim_getopt_info *goi, struct arm_cti *cti)
416 {
417  /* parse config or cget options ... */
418  while (goi->argc > 0) {
419  int e = adiv5_jim_mem_ap_spot_configure(&cti->spot, goi);
420 
421  if (e == JIM_CONTINUE)
422  Jim_SetResultFormatted(goi->interp, "unknown option '%s'",
423  Jim_String(goi->argv[0]));
424 
425  if (e != JIM_OK)
426  return JIM_ERR;
427  }
428 
429  if (!cti->spot.dap) {
430  Jim_SetResultString(goi->interp, "-dap required when creating CTI", -1);
431  return JIM_ERR;
432  }
433 
434  return JIM_OK;
435 }
436 
437 static int cti_create(struct jim_getopt_info *goi)
438 {
439  struct command_context *cmd_ctx;
440  static struct arm_cti *cti;
441  Jim_Obj *new_cmd;
442  Jim_Cmd *cmd;
443  const char *cp;
444  int e;
445 
446  cmd_ctx = current_command_context(goi->interp);
447  assert(cmd_ctx);
448 
449  if (goi->argc < 3) {
450  Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ..options...");
451  return JIM_ERR;
452  }
453  /* COMMAND */
454  jim_getopt_obj(goi, &new_cmd);
455  /* does this command exist? */
456  cmd = Jim_GetCommand(goi->interp, new_cmd, JIM_NONE);
457  if (cmd) {
458  cp = Jim_GetString(new_cmd, NULL);
459  Jim_SetResultFormatted(goi->interp, "Command: %s Exists", cp);
460  return JIM_ERR;
461  }
462 
463  /* Create it */
464  cti = calloc(1, sizeof(*cti));
465  if (!cti)
466  return JIM_ERR;
467 
469 
470  /* Do the rest as "configure" options */
471  goi->isconfigure = 1;
472  e = cti_configure(goi, cti);
473  if (e != JIM_OK) {
474  free(cti);
475  return e;
476  }
477 
478  cp = Jim_GetString(new_cmd, NULL);
479  cti->name = strdup(cp);
480 
481  /* now - create the new cti name command */
482  const struct command_registration cti_subcommands[] = {
483  {
485  },
487  };
488  const struct command_registration cti_commands[] = {
489  {
490  .name = cp,
491  .mode = COMMAND_ANY,
492  .help = "cti instance command group",
493  .usage = "",
494  .chain = cti_subcommands,
495  },
497  };
498  e = register_commands_with_data(cmd_ctx, NULL, cti_commands, cti);
499  if (e != ERROR_OK)
500  return JIM_ERR;
501 
502  list_add_tail(&cti->lh, &all_cti);
503 
504  cti->ap = dap_get_ap(cti->spot.dap, cti->spot.ap_num);
505  if (!cti->ap) {
506  Jim_SetResultString(goi->interp, "Cannot get AP", -1);
507  return JIM_ERR;
508  }
509 
510  return JIM_OK;
511 }
512 
513 static int jim_cti_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
514 {
515  struct jim_getopt_info goi;
516  jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
517  if (goi.argc < 2) {
518  Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv,
519  "<name> [<cti_options> ...]");
520  return JIM_ERR;
521  }
522  return cti_create(&goi);
523 }
524 
525 COMMAND_HANDLER(cti_handle_names)
526 {
527  struct arm_cti *obj;
528 
529  if (CMD_ARGC != 0)
531 
532  list_for_each_entry(obj, &all_cti, lh)
533  command_print(CMD, "%s", obj->name);
534 
535  return ERROR_OK;
536 }
537 
538 static const struct command_registration cti_subcommand_handlers[] = {
539  {
540  .name = "create",
541  .mode = COMMAND_ANY,
542  .jim_handler = jim_cti_create,
543  .usage = "name '-chain-position' name [options ...]",
544  .help = "Creates a new CTI object",
545  },
546  {
547  .name = "names",
548  .mode = COMMAND_ANY,
549  .handler = cti_handle_names,
550  .usage = "",
551  .help = "Lists all registered CTI objects by name",
552  },
554 };
555 
556 static const struct command_registration cti_command_handlers[] = {
557  {
558  .name = "cti",
559  .mode = COMMAND_CONFIG,
560  .help = "CTI commands",
561  .chain = cti_subcommand_handlers,
562  .usage = "",
563  },
565 };
566 
568 {
569  return register_commands(cmd_ctx, NULL, cti_command_handlers);
570 }
int mem_ap_read_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t *value)
Asynchronous (queued) read of a word from memory or a system register.
Definition: arm_adi_v5.c:237
int adiv5_mem_ap_spot_init(struct adiv5_mem_ap_spot *p)
Definition: arm_adi_v5.c:2501
int mem_ap_read_atomic_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t *value)
Synchronous read of a word from memory or a system register.
Definition: arm_adi_v5.c:266
struct adiv5_ap * dap_get_ap(struct adiv5_dap *dap, uint64_t ap_num)
Definition: arm_adi_v5.c:1189
int dap_put_ap(struct adiv5_ap *ap)
Definition: arm_adi_v5.c:1209
int adiv5_jim_mem_ap_spot_configure(struct adiv5_mem_ap_spot *cfg, struct jim_getopt_info *goi)
Definition: arm_adi_v5.c:2495
int mem_ap_write_atomic_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t value)
Synchronous write of a word to memory or a system register.
Definition: arm_adi_v5.c:318
This defines formats and data structures used to talk to ADIv5 entities.
static int dap_run(struct adiv5_dap *dap)
Perform all queued DAP operations, and clear any errors posted in the CTRL_STAT register when they ar...
Definition: arm_adi_v5.h:648
static int cti_find_reg_offset(const char *name)
Definition: arm_cti.c:195
int arm_cti_clear_channel(struct arm_cti *self, uint32_t channel)
Definition: arm_cti.c:152
int arm_cti_ack_events(struct arm_cti *self, uint32_t event)
Definition: arm_cti.c:81
int arm_cti_write_reg(struct arm_cti *self, unsigned int reg, uint32_t value)
Definition: arm_cti.c:123
static int cti_configure(struct jim_getopt_info *goi, struct arm_cti *cti)
Definition: arm_cti.c:415
COMMAND_HANDLER(handle_cti_dump)
Definition: arm_cti.c:220
static int jim_cti_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Definition: arm_cti.c:513
int cti_register_commands(struct command_context *cmd_ctx)
Definition: arm_cti.c:567
int arm_cti_gate_channel(struct arm_cti *self, uint32_t channel)
Definition: arm_cti.c:107
uint32_t offset
Definition: arm_cti.c:161
int arm_cti_set_channel(struct arm_cti *self, uint32_t channel)
Definition: arm_cti.c:144
static const struct command_registration cti_subcommand_handlers[]
Definition: arm_cti.c:538
int arm_cti_pulse_channel(struct arm_cti *self, uint32_t channel)
Definition: arm_cti.c:136
static const struct command_registration cti_instance_command_handlers[]
Definition: arm_cti.c:361
static int cti_create(struct jim_getopt_info *goi)
Definition: arm_cti.c:437
const char * label
Definition: arm_cti.c:162
static LIST_HEAD(all_cti)
int arm_cti_enable(struct arm_cti *self, bool enable)
Definition: arm_cti.c:74
int arm_cti_cleanup_all(void)
Definition: arm_cti.c:206
const char * arm_cti_name(struct arm_cti *self)
Definition: arm_cti.c:30
static int arm_cti_mod_reg_bits(struct arm_cti *self, unsigned int reg, uint32_t mask, uint32_t value)
Definition: arm_cti.c:55
static const struct @63 cti_names[]
int arm_cti_read_reg(struct arm_cti *self, unsigned int reg, uint32_t *p_value)
Definition: arm_cti.c:128
struct arm_cti * cti_instance_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
Definition: arm_cti.c:35
int arm_cti_ungate_channel(struct arm_cti *self, uint32_t channel)
Definition: arm_cti.c:115
static const struct command_registration cti_command_handlers[]
Definition: arm_cti.c:556
#define CTI_OUTEN3
Definition: arm_cti.h:30
#define CTI_OUTEN6
Definition: arm_cti.h:33
#define CTI_INACK
Definition: arm_cti.h:13
#define CTI_CHNL(x)
Definition: arm_cti.h:45
#define CTI_INEN8
Definition: arm_cti.h:25
#define CTI_APPSET
Definition: arm_cti.h:14
#define CTI_INEN1
Definition: arm_cti.h:18
#define CTI_INEN4
Definition: arm_cti.h:21
#define CTI_OUTEN4
Definition: arm_cti.h:31
#define CTI_INEN3
Definition: arm_cti.h:20
#define CTI_INEN5
Definition: arm_cti.h:22
#define CTI_TROUT_STATUS
Definition: arm_cti.h:38
#define CTI_GATE
Definition: arm_cti.h:41
#define CTI_OUTEN2
Definition: arm_cti.h:29
#define CTI_APPPULSE
Definition: arm_cti.h:16
#define CTI_CTR
Definition: arm_cti.h:12
#define CTI_INEN7
Definition: arm_cti.h:24
#define CTI_INEN0
Definition: arm_cti.h:17
#define CTI_CHIN_STATUS
Definition: arm_cti.h:39
#define CTI_DEVCTL
Definition: arm_cti.h:42
#define CTI_OUTEN8
Definition: arm_cti.h:35
#define CTI_OUTEN0
Definition: arm_cti.h:27
#define CTI_TRIN_STATUS
Definition: arm_cti.h:37
#define CTI_OUTEN7
Definition: arm_cti.h:34
#define CTI_CHOU_STATUS
Definition: arm_cti.h:40
#define CTI_INEN2
Definition: arm_cti.h:19
#define CTI_APPCLEAR
Definition: arm_cti.h:15
#define CTI_OUTEN5
Definition: arm_cti.h:32
#define CTI_OUTEN1
Definition: arm_cti.h:28
#define CTI_INEN6
Definition: arm_cti.h:23
const char * name
Definition: armv4_5.c:76
struct command_context * current_command_context(Jim_Interp *interp)
Definition: command.c:157
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:443
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:156
static int register_commands_with_data(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds, void *data)
Register one or more commands, as register_commands(), plus specify a pointer to command private data...
Definition: command.h:315
#define COMMAND_PARSE_ON_OFF(in, out)
parses an on/off command argument
Definition: command.h:530
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:402
#define CMD_DATA
Use this macro to access the invoked command handler's data pointer, rather than accessing the variab...
Definition: command.h:176
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
Definition: command.h:442
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
#define ERROR_COMMAND_ARGUMENT_INVALID
Definition: command.h:404
static int register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds)
Register one or more commands in the specified context, as children of parent (or top-level commends,...
Definition: command.h:274
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
int mask
Definition: esirisc.c:1741
int jim_getopt_setup(struct jim_getopt_info *p, Jim_Interp *interp, int argc, Jim_Obj *const *argv)
GetOpt - how to.
Definition: jim-nvp.c:149
int jim_getopt_obj(struct jim_getopt_info *goi, Jim_Obj **puthere)
Remove argv[0] from the list.
Definition: jim-nvp.c:169
static void list_add_tail(struct list_head *new, struct list_head *head)
Definition: list.h:199
#define list_for_each_entry_safe(p, n, h, field)
Definition: list.h:155
#define list_for_each_entry(p, h, field)
Definition: list.h:151
#define ERROR_FAIL
Definition: log.h:170
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define ERROR_OK
Definition: log.h:164
static uint32_t lh(unsigned int rd, unsigned int base, uint16_t offset) __attribute__((unused))
Definition: opcodes.h:117
This represents an ARM Debug Interface (v5) Access Port (AP).
Definition: arm_adi_v5.h:250
struct adiv5_dap * dap
DAP this AP belongs to.
Definition: arm_adi_v5.h:254
struct adiv5_dap * dap
Definition: arm_adi_v5.h:803
struct adiv5_ap * ap
Definition: arm_cti.c:25
struct list_head lh
Definition: arm_cti.c:22
struct adiv5_mem_ap_spot spot
Definition: arm_cti.c:24
char * name
Definition: arm_cti.c:23
const char * name
Definition: command.h:235
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
Definition: command.h:249
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:241
A TCL -ish GetOpt like code.
Definition: jim-nvp.h:135
Jim_Interp * interp
Definition: jim-nvp.h:136
Jim_Obj *const * argv
Definition: jim-nvp.h:138
Definition: list.h:40
Definition: register.h:111
#define ERROR_TARGET_TIMEOUT
Definition: target.h:789
int64_t timeval_ms(void)
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
Definition: types.h:57
#define NULL
Definition: usb.h:16
uint8_t cmd
Definition: vdebug.c:1