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_coresight.h"
15 #include "target/arm_adi_v5.h"
16 #include "target/arm_cti.h"
17 #include "target/target.h"
18 #include "helper/time_support.h"
19 #include "helper/list.h"
20 #include "helper/command.h"
21 
22 struct arm_cti {
23  struct list_head lh;
24  char *name;
25  struct adiv5_mem_ap_spot spot;
26  struct adiv5_ap *ap;
27 };
28 
29 static OOCD_LIST_HEAD(all_cti);
30 
31 const char *arm_cti_name(struct arm_cti *self)
32 {
33  return self->name;
34 }
35 
36 struct arm_cti *cti_instance_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
37 {
38  struct arm_cti *obj = NULL;
39  const char *name;
40  bool found = false;
41 
42  name = Jim_GetString(o, NULL);
43 
44  list_for_each_entry(obj, &all_cti, lh) {
45  if (!strcmp(name, obj->name)) {
46  found = true;
47  break;
48  }
49  }
50 
51  if (found)
52  return obj;
53  return NULL;
54 }
55 
56 static void arm_cti_unlock(struct arm_cti *self)
57 {
58  /* while the LAR /shouldn't/ affect "accesses that use the external
59  * debugger interface" according to ARM's docs, it certainly does so,
60  * at least on NXP's LX2160A
61  */
62  mem_ap_write_atomic_u32(self->ap, self->spot.base + ARM_CS_LAR,
64 }
65 
66 static int arm_cti_mod_reg_bits(struct arm_cti *self, unsigned int reg, uint32_t mask, uint32_t value)
67 {
68  struct adiv5_ap *ap = self->ap;
69  uint32_t tmp;
70 
71  arm_cti_unlock(self);
72 
73  /* Read register */
74  int retval = mem_ap_read_atomic_u32(ap, self->spot.base + reg, &tmp);
75  if (retval != ERROR_OK)
76  return retval;
77 
78  /* clear bitfield */
79  tmp &= ~mask;
80  /* put new value */
81  tmp |= value & mask;
82 
83  /* write new value */
84  return mem_ap_write_atomic_u32(ap, self->spot.base + reg, tmp);
85 }
86 
87 int arm_cti_enable(struct arm_cti *self, bool enable)
88 {
89  uint32_t val = enable ? 1 : 0;
90 
91  arm_cti_unlock(self);
92 
93  return mem_ap_write_atomic_u32(self->ap, self->spot.base + CTI_CTR, val);
94 }
95 
96 int arm_cti_ack_events(struct arm_cti *self, uint32_t event)
97 {
98  struct adiv5_ap *ap = self->ap;
99  int retval;
100  uint32_t tmp;
101 
102  arm_cti_unlock(self);
103 
104  retval = mem_ap_write_atomic_u32(ap, self->spot.base + CTI_INACK, event);
105  if (retval == ERROR_OK) {
106  int64_t then = timeval_ms();
107  for (;;) {
108  retval = mem_ap_read_atomic_u32(ap, self->spot.base + CTI_TROUT_STATUS, &tmp);
109  if (retval != ERROR_OK)
110  break;
111  if ((tmp & event) == 0)
112  break;
113  if (timeval_ms() > then + 1000) {
114  LOG_ERROR("timeout waiting for target");
115  retval = ERROR_TARGET_TIMEOUT;
116  break;
117  }
118  }
119  }
120 
121  return retval;
122 }
123 
124 int arm_cti_gate_channel(struct arm_cti *self, uint32_t channel)
125 {
126  if (channel > 31)
128 
129  return arm_cti_mod_reg_bits(self, CTI_GATE, CTI_CHNL(channel), 0);
130 }
131 
132 int arm_cti_ungate_channel(struct arm_cti *self, uint32_t channel)
133 {
134  if (channel > 31)
136 
137  return arm_cti_mod_reg_bits(self, CTI_GATE, CTI_CHNL(channel), 0xFFFFFFFF);
138 }
139 
140 int arm_cti_write_reg(struct arm_cti *self, unsigned int reg, uint32_t value)
141 {
142  arm_cti_unlock(self);
143 
144  return mem_ap_write_atomic_u32(self->ap, self->spot.base + reg, value);
145 }
146 
147 int arm_cti_read_reg(struct arm_cti *self, unsigned int reg, uint32_t *p_value)
148 {
149  if (!p_value)
151 
152  return mem_ap_read_atomic_u32(self->ap, self->spot.base + reg, p_value);
153 }
154 
155 int arm_cti_pulse_channel(struct arm_cti *self, uint32_t channel)
156 {
157  if (channel > 31)
159 
160  return arm_cti_write_reg(self, CTI_APPPULSE, CTI_CHNL(channel));
161 }
162 
163 int arm_cti_set_channel(struct arm_cti *self, uint32_t channel)
164 {
165  if (channel > 31)
167 
168  return arm_cti_write_reg(self, CTI_APPSET, CTI_CHNL(channel));
169 }
170 
171 int arm_cti_clear_channel(struct arm_cti *self, uint32_t channel)
172 {
173  if (channel > 31)
175 
176  return arm_cti_write_reg(self, CTI_APPCLEAR, CTI_CHNL(channel));
177 }
178 
179 static const struct {
180  uint32_t offset;
181  const char *label;
182 } cti_names[] = {
183  { CTI_CTR, "CTR" },
184  { CTI_GATE, "GATE" },
185  { CTI_INEN0, "INEN0" },
186  { CTI_INEN1, "INEN1" },
187  { CTI_INEN2, "INEN2" },
188  { CTI_INEN3, "INEN3" },
189  { CTI_INEN4, "INEN4" },
190  { CTI_INEN5, "INEN5" },
191  { CTI_INEN6, "INEN6" },
192  { CTI_INEN7, "INEN7" },
193  { CTI_INEN8, "INEN8" },
194  { CTI_OUTEN0, "OUTEN0" },
195  { CTI_OUTEN1, "OUTEN1" },
196  { CTI_OUTEN2, "OUTEN2" },
197  { CTI_OUTEN3, "OUTEN3" },
198  { CTI_OUTEN4, "OUTEN4" },
199  { CTI_OUTEN5, "OUTEN5" },
200  { CTI_OUTEN6, "OUTEN6" },
201  { CTI_OUTEN7, "OUTEN7" },
202  { CTI_OUTEN8, "OUTEN8" },
203  { CTI_TRIN_STATUS, "TRIN" },
204  { CTI_TROUT_STATUS, "TROUT" },
205  { CTI_CHIN_STATUS, "CHIN" },
206  { CTI_CHOU_STATUS, "CHOUT" },
207  { CTI_APPSET, "APPSET" },
208  { CTI_APPCLEAR, "APPCLR" },
209  { CTI_APPPULSE, "APPPULSE" },
210  { CTI_INACK, "INACK" },
211  { CTI_DEVCTL, "DEVCTL" },
212  { ARM_CS_LAR, "LAR" },
213  { ARM_CS_LSR, "LSR" },
214  { ARM_CS_AUTHSTATUS, "AUTHSTATUS" },
215 };
216 
217 static int cti_find_reg_offset(const char *name)
218 {
219  for (size_t i = 0; i < ARRAY_SIZE(cti_names); i++) {
220  if (!strcmp(name, cti_names[i].label))
221  return cti_names[i].offset;
222  }
223 
224  LOG_ERROR("unknown CTI register %s", name);
225  return -1;
226 }
227 
229 {
230  struct arm_cti *obj, *tmp;
231 
232  list_for_each_entry_safe(obj, tmp, &all_cti, lh) {
233  if (obj->ap)
234  dap_put_ap(obj->ap);
235  free(obj->name);
236  free(obj);
237  }
238 
239  return ERROR_OK;
240 }
241 
242 COMMAND_HANDLER(handle_cti_dump)
243 {
244  struct arm_cti *cti = CMD_DATA;
245  struct adiv5_ap *ap = cti->ap;
246  int retval = ERROR_OK;
247  uint32_t values[ARRAY_SIZE(cti_names)];
248 
249  for (size_t i = 0; (retval == ERROR_OK) && (i < ARRAY_SIZE(cti_names)); i++)
250  retval = mem_ap_read_u32(ap,
251  cti->spot.base + cti_names[i].offset, &values[i]);
252 
253  if (retval == ERROR_OK)
254  retval = dap_run(ap->dap);
255 
256  if (retval != ERROR_OK)
257  return retval;
258 
259  for (size_t i = 0; i < ARRAY_SIZE(cti_names); i++)
260  command_print(CMD, "%8.8s (0x%04"PRIx32") 0x%08"PRIx32,
261  cti_names[i].label, cti_names[i].offset, values[i]);
262 
263  return ERROR_OK;
264 }
265 
266 COMMAND_HANDLER(handle_cti_enable)
267 {
268  struct arm_cti *cti = CMD_DATA;
269  bool on_off;
270 
271  if (CMD_ARGC != 1)
273 
274  COMMAND_PARSE_ON_OFF(CMD_ARGV[0], on_off);
275 
276  return arm_cti_enable(cti, on_off);
277 }
278 
279 COMMAND_HANDLER(handle_cti_testmode)
280 {
281  struct arm_cti *cti = CMD_DATA;
282  bool on_off;
283 
284  if (CMD_ARGC != 1)
286 
287  COMMAND_PARSE_ON_OFF(CMD_ARGV[0], on_off);
288 
289  return arm_cti_write_reg(cti, 0xf00, on_off ? 0x1 : 0x0);
290 }
291 
292 COMMAND_HANDLER(handle_cti_write)
293 {
294  struct arm_cti *cti = CMD_DATA;
295  int offset;
296  uint32_t value;
297 
298  if (CMD_ARGC != 2)
300 
302  if (offset < 0)
303  return ERROR_FAIL;
304 
305  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value);
306 
307  return arm_cti_write_reg(cti, offset, value);
308 }
309 
310 COMMAND_HANDLER(handle_cti_read)
311 {
312  struct arm_cti *cti = CMD_DATA;
313  int offset;
314  int retval;
315  uint32_t value;
316 
317  if (CMD_ARGC != 1)
319 
321  if (offset < 0)
322  return ERROR_FAIL;
323 
324  retval = arm_cti_read_reg(cti, offset, &value);
325  if (retval != ERROR_OK)
326  return retval;
327 
328  command_print(CMD, "0x%08"PRIx32, value);
329 
330  return ERROR_OK;
331 }
332 
333 COMMAND_HANDLER(handle_cti_ack)
334 {
335  struct arm_cti *cti = CMD_DATA;
336  uint32_t event;
337 
338  if (CMD_ARGC != 1)
340 
341  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], event);
342 
343  int retval = arm_cti_ack_events(cti, 1 << event);
344 
345  if (retval != ERROR_OK)
346  return retval;
347 
348  return ERROR_OK;
349 }
350 
351 COMMAND_HANDLER(handle_cti_channel)
352 {
353  struct arm_cti *cti = CMD_DATA;
354  int retval = ERROR_OK;
355  uint32_t ch_num;
356 
357  if (CMD_ARGC != 2)
359 
360  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], ch_num);
361 
362  if (!strcmp(CMD_ARGV[1], "gate"))
363  retval = arm_cti_gate_channel(cti, ch_num);
364  else if (!strcmp(CMD_ARGV[1], "ungate"))
365  retval = arm_cti_ungate_channel(cti, ch_num);
366  else if (!strcmp(CMD_ARGV[1], "pulse"))
367  retval = arm_cti_pulse_channel(cti, ch_num);
368  else if (!strcmp(CMD_ARGV[1], "set"))
369  retval = arm_cti_set_channel(cti, ch_num);
370  else if (!strcmp(CMD_ARGV[1], "clear"))
371  retval = arm_cti_clear_channel(cti, ch_num);
372  else {
373  command_print(CMD, "Possible channel operations: gate|ungate|set|clear|pulse");
375  }
376 
377  if (retval != ERROR_OK)
378  return retval;
379 
380  return ERROR_OK;
381 }
382 
383 static const struct command_registration cti_instance_command_handlers[] = {
384  {
385  .name = "dump",
386  .mode = COMMAND_EXEC,
387  .handler = handle_cti_dump,
388  .help = "dump CTI registers",
389  .usage = "",
390  },
391  {
392  .name = "enable",
393  .mode = COMMAND_EXEC,
394  .handler = handle_cti_enable,
395  .help = "enable or disable the CTI",
396  .usage = "'on'|'off'",
397  },
398  {
399  .name = "testmode",
400  .mode = COMMAND_EXEC,
401  .handler = handle_cti_testmode,
402  .help = "enable or disable integration test mode",
403  .usage = "'on'|'off'",
404  },
405  {
406  .name = "write",
407  .mode = COMMAND_EXEC,
408  .handler = handle_cti_write,
409  .help = "write to a CTI register",
410  .usage = "register_name value",
411  },
412  {
413  .name = "read",
414  .mode = COMMAND_EXEC,
415  .handler = handle_cti_read,
416  .help = "read a CTI register",
417  .usage = "register_name",
418  },
419  {
420  .name = "ack",
421  .mode = COMMAND_EXEC,
422  .handler = handle_cti_ack,
423  .help = "acknowledge a CTI event",
424  .usage = "event",
425  },
426  {
427  .name = "channel",
428  .mode = COMMAND_EXEC,
429  .handler = handle_cti_channel,
430  .help = "do an operation on one CTI channel, possible operations: "
431  "gate, ungate, set, clear and pulse",
432  .usage = "channel_number operation",
433  },
435 };
436 
437 static int cti_configure(struct jim_getopt_info *goi, struct arm_cti *cti)
438 {
439  /* parse config or cget options ... */
440  while (goi->argc > 0) {
441  int e = adiv5_jim_mem_ap_spot_configure(&cti->spot, goi);
442 
443  if (e == JIM_CONTINUE)
444  Jim_SetResultFormatted(goi->interp, "unknown option '%s'",
445  Jim_String(goi->argv[0]));
446 
447  if (e != JIM_OK)
448  return JIM_ERR;
449  }
450 
451  if (!cti->spot.dap) {
452  Jim_SetResultString(goi->interp, "-dap required when creating CTI", -1);
453  return JIM_ERR;
454  }
455 
456  return JIM_OK;
457 }
458 
459 COMMAND_HANDLER(handle_cti_create)
460 {
461  if (CMD_ARGC < 3)
463 
464  /* check if the cti name clashes with an existing command name */
465  Jim_Cmd *jimcmd = Jim_GetCommand(CMD_CTX->interp, CMD_JIMTCL_ARGV[0], JIM_NONE);
466  if (jimcmd) {
467  command_print(CMD, "Command/cti: %s Exists", CMD_ARGV[0]);
468  return ERROR_FAIL;
469  }
470 
471  /* Create it */
472  struct arm_cti *cti = calloc(1, sizeof(*cti));
473  if (!cti) {
474  LOG_ERROR("Out of memory");
475  return ERROR_FAIL;
476  }
477 
479 
480  /* Do the rest as "configure" options */
481  struct jim_getopt_info goi;
482  jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC - 1, CMD_JIMTCL_ARGV + 1);
483  goi.is_configure = 1;
484  int e = cti_configure(&goi, cti);
485  if (e != JIM_OK) {
486  int reslen;
487  const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
488  if (reslen > 0)
489  command_print(CMD, "%s", result);
490  free(cti);
492  }
493 
494  cti->name = strdup(CMD_ARGV[0]);
495  if (!cti->name) {
496  LOG_ERROR("Out of memory");
497  free(cti);
498  return ERROR_FAIL;
499  }
500 
501  /* now - create the new cti name command */
502  const struct command_registration cti_subcommands[] = {
503  {
505  },
507  };
508  const struct command_registration cti_commands[] = {
509  {
510  .name = CMD_ARGV[0],
511  .mode = COMMAND_ANY,
512  .help = "cti instance command group",
513  .usage = "",
514  .chain = cti_subcommands,
515  },
517  };
518  int retval = register_commands_with_data(CMD_CTX, NULL, cti_commands, cti);
519  if (retval != ERROR_OK) {
520  free(cti->name);
521  free(cti);
522  return retval;
523  }
524 
525  list_add_tail(&cti->lh, &all_cti);
526 
527  cti->ap = dap_get_ap(cti->spot.dap, cti->spot.ap_num);
528  if (!cti->ap) {
529  command_print(CMD, "Cannot get AP");
530  free(cti->name);
531  free(cti);
532  return ERROR_FAIL;
533  }
534 
535  return ERROR_OK;
536 }
537 
538 COMMAND_HANDLER(cti_handle_names)
539 {
540  struct arm_cti *obj;
541 
542  if (CMD_ARGC != 0)
544 
545  list_for_each_entry(obj, &all_cti, lh)
546  command_print(CMD, "%s", obj->name);
547 
548  return ERROR_OK;
549 }
550 
551 static const struct command_registration cti_subcommand_handlers[] = {
552  {
553  .name = "create",
554  .mode = COMMAND_ANY,
555  .handler = handle_cti_create,
556  .usage = "name '-chain-position' name [options ...]",
557  .help = "Creates a new CTI object",
558  },
559  {
560  .name = "names",
561  .mode = COMMAND_ANY,
562  .handler = cti_handle_names,
563  .usage = "",
564  .help = "Lists all registered CTI objects by name",
565  },
567 };
568 
569 static const struct command_registration cti_command_handlers[] = {
570  {
571  .name = "cti",
572  .mode = COMMAND_CONFIG,
573  .help = "CTI commands",
574  .chain = cti_subcommand_handlers,
575  .usage = "",
576  },
578 };
579 
581 {
582  return register_commands(cmd_ctx, NULL, cti_command_handlers);
583 }
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:245
int adiv5_mem_ap_spot_init(struct adiv5_mem_ap_spot *p)
Definition: arm_adi_v5.c:2536
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:274
struct adiv5_ap * dap_get_ap(struct adiv5_dap *dap, uint64_t ap_num)
Definition: arm_adi_v5.c:1222
int dap_put_ap(struct adiv5_ap *ap)
Definition: arm_adi_v5.c:1242
int adiv5_jim_mem_ap_spot_configure(struct adiv5_mem_ap_spot *cfg, struct jim_getopt_info *goi)
Definition: arm_adi_v5.c:2530
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:326
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
#define ARM_CS_LAR
Definition: arm_coresight.h:29
#define ARM_CS_LSR
Definition: arm_coresight.h:30
#define ARM_CS_AUTHSTATUS
Definition: arm_coresight.h:33
#define ARM_CS_LAR_UNLOCK_KEY
Definition: arm_coresight.h:35
static OOCD_LIST_HEAD(all_cti)
static int cti_find_reg_offset(const char *name)
Definition: arm_cti.c:217
int arm_cti_clear_channel(struct arm_cti *self, uint32_t channel)
Definition: arm_cti.c:171
int arm_cti_ack_events(struct arm_cti *self, uint32_t event)
Definition: arm_cti.c:96
int arm_cti_write_reg(struct arm_cti *self, unsigned int reg, uint32_t value)
Definition: arm_cti.c:140
static int cti_configure(struct jim_getopt_info *goi, struct arm_cti *cti)
Definition: arm_cti.c:437
COMMAND_HANDLER(handle_cti_dump)
Definition: arm_cti.c:242
int cti_register_commands(struct command_context *cmd_ctx)
Definition: arm_cti.c:580
int arm_cti_gate_channel(struct arm_cti *self, uint32_t channel)
Definition: arm_cti.c:124
static const struct @67 cti_names[]
uint32_t offset
Definition: arm_cti.c:180
int arm_cti_set_channel(struct arm_cti *self, uint32_t channel)
Definition: arm_cti.c:163
static const struct command_registration cti_subcommand_handlers[]
Definition: arm_cti.c:551
int arm_cti_pulse_channel(struct arm_cti *self, uint32_t channel)
Definition: arm_cti.c:155
static const struct command_registration cti_instance_command_handlers[]
Definition: arm_cti.c:383
const char * label
Definition: arm_cti.c:181
int arm_cti_enable(struct arm_cti *self, bool enable)
Definition: arm_cti.c:87
int arm_cti_cleanup_all(void)
Definition: arm_cti.c:228
const char * arm_cti_name(struct arm_cti *self)
Definition: arm_cti.c:31
static void arm_cti_unlock(struct arm_cti *self)
Definition: arm_cti.c:56
static int arm_cti_mod_reg_bits(struct arm_cti *self, unsigned int reg, uint32_t mask, uint32_t value)
Definition: arm_cti.c:66
int arm_cti_read_reg(struct arm_cti *self, unsigned int reg, uint32_t *p_value)
Definition: arm_cti.c:147
struct arm_cti * cti_instance_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
Definition: arm_cti.c:36
int arm_cti_ungate_channel(struct arm_cti *self, uint32_t channel)
Definition: arm_cti.c:132
static const struct command_registration cti_command_handlers[]
Definition: arm_cti.c:569
#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:44
#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
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:389
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:146
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:161
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:318
#define COMMAND_PARSE_ON_OFF(in, out)
parses an on/off command argument
Definition: command.h:533
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:405
#define CMD_DATA
Use this macro to access the invoked command handler's data pointer, rather than accessing the variab...
Definition: command.h:181
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:156
#define CMD_JIMTCL_ARGV
Use this macro to access the jimtcl arguments for the command being handled, rather than accessing th...
Definition: command.h:166
#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:445
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
Definition: command.h:151
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:256
#define ERROR_COMMAND_ARGUMENT_INVALID
Definition: command.h:407
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:277
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
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
static void list_add_tail(struct list_head *new, struct list_head *head)
Definition: list.h:203
#define list_for_each_entry_safe(p, n, h, field)
Definition: list.h:159
#define list_for_each_entry(p, h, field)
Definition: list.h:155
#define ERROR_FAIL
Definition: log.h:188
#define LOG_ERROR(expr ...)
Definition: log.h:147
#define ERROR_OK
Definition: log.h:182
static uint32_t lh(unsigned int rd, unsigned int base, int16_t offset) __attribute__((unused))
Definition: opcodes.h:172
uint8_t mask
Definition: parport.c:70
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:814
struct adiv5_ap * ap
Definition: arm_cti.c:26
struct list_head lh
Definition: arm_cti.c:23
struct adiv5_mem_ap_spot spot
Definition: arm_cti.c:25
char * name
Definition: arm_cti.c:24
const char * name
Definition: command.h:239
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:252
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:244
A TCL -ish GetOpt like code.
Definition: jim-nvp.h:136
Jim_Interp * interp
Definition: jim-nvp.h:137
bool is_configure
Definition: jim-nvp.h:140
Jim_Obj *const * argv
Definition: jim-nvp.h:139
Definition: list.h:41
Definition: register.h:111
#define ERROR_TARGET_TIMEOUT
Definition: target.h:816
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