1
2
3
10
11
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
74
75
81
82
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
124
125
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
208
209
210
211
212
213
214
215
216
217
218
219
226
227
228
229
230
231
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
258
259
260
261
262
263
264
265
266
267
268
269
275
276
277
278
279
280
281
282
283
284
285
286
291
292
293
294
295
296
297
298
299
300
301
302
303
304
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
365
366
367
368
369
370
371
372
373
374
375
376
377
378
382
383
384
385
386
387
388
389
390
394
395
400
401
402
409
410
411
412
413
417
418
419
420
421
428
429
430
431
432
436
437
438
439
452
465
466
467
468
469
470
471
479
480
484
485
486
492
493
494
505
506
507
508
509
510
511
512
516
517
523
524
525
534
535
536
537
538
539
540
541
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
569
570
571
572
573
574
581
582
583
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
614
615
616
617
618
624
625
629
630
631
632
642
643
644
645
646
647
652
656
657
658
659
660
661
662
663
664
665
666
667
668
669
676
677
678
679
680
681
682
683
687
700
705
706
717
718
719
720
721
722
723
724
728
729
730
731
732
736
743
744
745
746
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
859
860
861
862
863
864
865
866
867
868
869
870
871
872
879
886
893
900
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
926
927
928
938
939
940
941
942
943
944
945
946
947
948
949
950
951
955
956
957
961
962
963
964
965
966
970
971
972
973
974
978
979
980
981
982
983
984
985
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1048
1049
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1097
1098
1099
1100
1101
1102
1103
1104
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1231
1232
/* ... */
/* ... */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <jim.h>
#include <helper/bits.h>
#include <helper/command.h>
#include <helper/jim-nvp.h>
#include <helper/list.h>
#include <helper/log.h>
#include <helper/types.h>
#include <jtag/interface.h>
#include <server/server.h>
#include <target/arm_adi_v5.h>
#include <target/target.h>
#include <transport/transport.h>
#include "arm_tpiu_swo.h"
#include <target/cortex_m.h>
15 includes#define MSG "DEPRECATED \'tpiu config\' command: "
#define TCP_SERVICE_NAME "tpiu_swo_trace"
#define TPIU_SWO_DEFAULT_BASE 0xE0040000
#define TPIU_SSPSR_OFFSET 0x000
#define TPIU_CSPSR_OFFSET 0x004
#define TPIU_ACPR_OFFSET 0x010
#define TPIU_SPPR_OFFSET 0x0F0
#define TPIU_FFSR_OFFSET 0x300
#define TPIU_FFCR_OFFSET 0x304
#define TPIU_FSCR_OFFSET 0x308
#define TPIU_DEVID_OFFSET 0xfc8
#define TPIU_ACPR_MAX_PRESCALER 0x1fff
#define TPIU_SPPR_PROTOCOL_SYNC (TPIU_PIN_PROTOCOL_SYNC)
#define TPIU_SPPR_PROTOCOL_MANCHESTER (TPIU_PIN_PROTOCOL_ASYNC_MANCHESTER)
#define TPIU_SPPR_PROTOCOL_UART (TPIU_PIN_PROTOCOL_ASYNC_UART)
#define TPIU_DEVID_NOSUPPORT_SYNC BIT(9)
#define TPIU_DEVID_SUPPORT_MANCHESTER BIT(10)
#define TPIU_DEVID_SUPPORT_UART BIT(11)
18 defines
enum arm_tpiu_swo_event {
TPIU_SWO_EVENT_PRE_ENABLE,
TPIU_SWO_EVENT_POST_ENABLE,
TPIU_SWO_EVENT_PRE_DISABLE,
TPIU_SWO_EVENT_POST_DISABLE,
...};
static const struct jim_nvp nvp_arm_tpiu_swo_event[] = {
{ .value = TPIU_SWO_EVENT_PRE_ENABLE, .name = "pre-enable" },
{ .value = TPIU_SWO_EVENT_POST_ENABLE, .name = "post-enable" },
{ .value = TPIU_SWO_EVENT_PRE_DISABLE, .name = "pre-disable" },
{ .value = TPIU_SWO_EVENT_POST_DISABLE, .name = "post-disable" },
...};
struct arm_tpiu_swo_event_action {
enum arm_tpiu_swo_event event;
Jim_Interp *interp;
Jim_Obj *body;
struct arm_tpiu_swo_event_action *next;
...};
struct arm_tpiu_swo_object {
struct list_head lh;
struct adiv5_mem_ap_spot spot;
struct adiv5_ap *ap;
char *name;
struct arm_tpiu_swo_event_action *event_action;
bool deferred_enable;
bool enabled;
bool en_capture;
uint32_t port_width;
FILE *file;
unsigned int pin_protocol;
bool en_formatter;
unsigned int traceclkin_freq;
unsigned int swo_pin_freq;
char *out_filename;
struct list_head connections;
bool recheck_ap_cur_target;
...};
struct arm_tpiu_swo_connection {
struct list_head lh;
struct connection *connection;
...};
struct arm_tpiu_swo_priv_connection {
struct arm_tpiu_swo_object *obj;
...};
static LIST_HEAD(all_tpiu_swo);
#define ARM_TPIU_SWO_TRACE_BUF_SIZE 4096
static int arm_tpiu_swo_poll_trace(void *priv)
{
struct arm_tpiu_swo_object *obj = priv;
uint8_t buf[ARM_TPIU_SWO_TRACE_BUF_SIZE];
size_t size = sizeof(buf);
struct arm_tpiu_swo_connection *c;
int retval = adapter_poll_trace(buf, &size);
if (retval != ERROR_OK || !size)
return retval;
target_call_trace_callbacks(NULL, size, buf);
if (obj->file) {
if (fwrite(buf, 1, size, obj->file) == size) {
fflush(obj->file);
}if (fwrite(buf, 1, size, obj->file) == size) { ... } else {
LOG_ERROR("Error writing to the SWO trace destination file");
return ERROR_FAIL;
}else { ... }
}if (obj->file) { ... }
if (obj->out_filename[0] == ':')
list_for_each_entry(c, &obj->connections, lh)
if (connection_write(c->connection, buf, size) != (int)size)
LOG_ERROR("Error writing to connection");
return ERROR_OK;
}{ ... }
static int arm_tpiu_swo_handle_event(struct arm_tpiu_swo_object *obj, enum arm_tpiu_swo_event event)
{
for (struct arm_tpiu_swo_event_action *ea = obj->event_action; ea; ea = ea->next) {
if (ea->event != event)
continue;
LOG_DEBUG("TPIU/SWO: %s event: %s (%d) action : %s",
obj->name,
jim_nvp_value2name_simple(nvp_arm_tpiu_swo_event, event)->name,
event,
Jim_GetString(ea->body, NULL));
struct command_context *cmd_ctx = current_command_context(ea->interp);
struct target *saved_target = cmd_ctx->current_target;
int retval = Jim_EvalObj(ea->interp, ea->body);
cmd_ctx->current_target = saved_target;
if (retval == JIM_RETURN)
retval = ea->interp->returnCode;
if (retval == JIM_OK || retval == ERROR_COMMAND_CLOSE_CONNECTION)
return ERROR_OK;
Jim_MakeErrorMessage(ea->interp);
LOG_USER("Error executing event %s on TPIU/SWO %s:\n%s",
jim_nvp_value2name_simple(nvp_arm_tpiu_swo_event, event)->name,
obj->name,
Jim_GetString(Jim_GetResult(ea->interp), NULL));
Jim_Eval(ea->interp, "error \"\" \"\"");
return ERROR_FAIL;
}for (struct arm_tpiu_swo_event_action *ea = obj->event_action; ea; ea = ea->next) { ... }
return ERROR_OK;
}{ ... }
static void arm_tpiu_swo_close_output(struct arm_tpiu_swo_object *obj)
{
if (obj->file) {
fclose(obj->file);
obj->file = NULL;
}if (obj->file) { ... }
if (obj->out_filename[0] == ':')
remove_service(TCP_SERVICE_NAME, &obj->out_filename[1]);
}{ ... }
int arm_tpiu_swo_cleanup_all(void)
{
struct arm_tpiu_swo_object *obj, *tmp;
list_for_each_entry_safe(obj, tmp, &all_tpiu_swo, lh) {
if (obj->enabled)
arm_tpiu_swo_handle_event(obj, TPIU_SWO_EVENT_PRE_DISABLE);
arm_tpiu_swo_close_output(obj);
if (obj->en_capture) {
target_unregister_timer_callback(arm_tpiu_swo_poll_trace, obj);
int retval = adapter_config_trace(false, 0, 0, NULL, 0, NULL);
if (retval != ERROR_OK)
LOG_ERROR("Failed to stop adapter's trace");
}if (obj->en_capture) { ... }
if (obj->enabled)
arm_tpiu_swo_handle_event(obj, TPIU_SWO_EVENT_POST_DISABLE);
struct arm_tpiu_swo_event_action *ea = obj->event_action;
while (ea) {
struct arm_tpiu_swo_event_action *next = ea->next;
Jim_DecrRefCount(ea->interp, ea->body);
free(ea);
ea = next;
}while (ea) { ... }
if (obj->ap)
dap_put_ap(obj->ap);
free(obj->name);
free(obj->out_filename);
free(obj);
}list_for_each_entry_safe (obj, tmp, &all_tpiu_swo, lh) { ... }
return ERROR_OK;
}{ ... }
static int arm_tpiu_swo_service_new_connection(struct connection *connection)
{
struct arm_tpiu_swo_priv_connection *priv = connection->service->priv;
struct arm_tpiu_swo_object *obj = priv->obj;
struct arm_tpiu_swo_connection *c = malloc(sizeof(*c));
if (!c) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}if (!c) { ... }
c->connection = connection;
list_add(&c->lh, &obj->connections);
return ERROR_OK;
}{ ... }
static int arm_tpiu_swo_service_input(struct connection *connection)
{
long dummy;
int bytes_read = connection_read(connection, &dummy, sizeof(dummy));
if (bytes_read == 0) {
return ERROR_SERVER_REMOTE_CLOSED;
}if (bytes_read == 0) { ... } else if (bytes_read == -1) {
LOG_ERROR("error during read: %s", strerror(errno));
return ERROR_SERVER_REMOTE_CLOSED;
}else if (bytes_read == -1) { ... }
return ERROR_OK;
}{ ... }
static int arm_tpiu_swo_service_connection_closed(struct connection *connection)
{
struct arm_tpiu_swo_priv_connection *priv = connection->service->priv;
struct arm_tpiu_swo_object *obj = priv->obj;
struct arm_tpiu_swo_connection *c, *tmp;
list_for_each_entry_safe(c, tmp, &obj->connections, lh)
if (c->connection == connection) {
list_del(&c->lh);
free(c);
return ERROR_OK;
}if (c->connection == connection) { ... }
LOG_ERROR("Failed to find connection to close!");
return ERROR_FAIL;
}{ ... }
COMMAND_HANDLER(handle_arm_tpiu_swo_event_list)
{
struct arm_tpiu_swo_object *obj = CMD_DATA;
command_print(CMD, "Event actions for TPIU/SWO %s\n", obj->name);
command_print(CMD, "%-25s | Body", "Event");
command_print(CMD, "------------------------- | "
"----------------------------------------");
for (struct arm_tpiu_swo_event_action *ea = obj->event_action; ea; ea = ea->next) {
struct jim_nvp *opt = jim_nvp_value2name_simple(nvp_arm_tpiu_swo_event, ea->event);
command_print(CMD, "%-25s | %s",
opt->name, Jim_GetString(ea->body, NULL));
}for (struct arm_tpiu_swo_event_action *ea = obj->event_action; ea; ea = ea->next) { ... }
command_print(CMD, "***END***");
return ERROR_OK;
}{ ... }
enum arm_tpiu_swo_cfg_param {
CFG_PORT_WIDTH,
CFG_PROTOCOL,
CFG_FORMATTER,
CFG_TRACECLKIN,
CFG_BITRATE,
CFG_OUTFILE,
CFG_EVENT,
...};
static const struct jim_nvp nvp_arm_tpiu_swo_config_opts[] = {
{ .name = "-port-width", .value = CFG_PORT_WIDTH },
{ .name = "-protocol", .value = CFG_PROTOCOL },
{ .name = "-formatter", .value = CFG_FORMATTER },
{ .name = "-traceclk", .value = CFG_TRACECLKIN },
{ .name = "-pin-freq", .value = CFG_BITRATE },
{ .name = "-output", .value = CFG_OUTFILE },
{ .name = "-event", .value = CFG_EVENT },
{ .name = "-dap", .value = -1 },
{ .name = "-ap-num", .value = -1 },
{ .name = "-baseaddr", .value = -1 },
{ .name = NULL, .value = -1 },
...};
static const struct jim_nvp nvp_arm_tpiu_swo_protocol_opts[] = {
{ .name = "sync", .value = TPIU_SPPR_PROTOCOL_SYNC },
{ .name = "uart", .value = TPIU_SPPR_PROTOCOL_UART },
{ .name = "manchester", .value = TPIU_SPPR_PROTOCOL_MANCHESTER },
{ .name = NULL, .value = -1 },
...};
static const struct jim_nvp nvp_arm_tpiu_swo_bool_opts[] = {
{ .name = "on", .value = 1 },
{ .name = "yes", .value = 1 },
{ .name = "1", .value = 1 },
{ .name = "true", .value = 1 },
{ .name = "off", .value = 0 },
{ .name = "no", .value = 0 },
{ .name = "0", .value = 0 },
{ .name = "false", .value = 0 },
{ .name = NULL, .value = -1 },
...};
static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_swo_object *obj)
{
assert(obj);
if (goi->isconfigure && obj->enabled) {
Jim_SetResultFormatted(goi->interp, "Cannot configure TPIU/SWO; %s is enabled!", obj->name);
return JIM_ERR;
}if (goi->isconfigure && obj->enabled) { ... }
while (goi->argc > 0) {
Jim_SetEmptyResult(goi->interp);
int e = adiv5_jim_mem_ap_spot_configure(&obj->spot, goi);
if (e == JIM_OK)
continue;
if (e == JIM_ERR)
return e;
struct jim_nvp *n;
e = jim_getopt_nvp(goi, nvp_arm_tpiu_swo_config_opts, &n);
if (e != JIM_OK) {
jim_getopt_nvp_unknown(goi, nvp_arm_tpiu_swo_config_opts, 0);
return e;
}if (e != JIM_OK) { ... }
switch (n->value) {
case CFG_PORT_WIDTH:
if (goi->isconfigure) {
jim_wide port_width;
e = jim_getopt_wide(goi, &port_width);
if (e != JIM_OK)
return e;
if (port_width < 1 || port_width > 32) {
Jim_SetResultString(goi->interp, "Invalid port width!", -1);
return JIM_ERR;
}if (port_width < 1 || port_width > 32) { ... }
obj->port_width = (uint32_t)port_width;
}if (goi->isconfigure) { ... } else {
if (goi->argc)
goto err_no_params;
Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, obj->port_width));
}else { ... }
break;case CFG_PORT_WIDTH:
case CFG_PROTOCOL:
if (goi->isconfigure) {
struct jim_nvp *p;
e = jim_getopt_nvp(goi, nvp_arm_tpiu_swo_protocol_opts, &p);
if (e != JIM_OK)
return e;
obj->pin_protocol = p->value;
}if (goi->isconfigure) { ... } else {
if (goi->argc)
goto err_no_params;
struct jim_nvp *p;
e = jim_nvp_value2name(goi->interp, nvp_arm_tpiu_swo_protocol_opts, obj->pin_protocol, &p);
if (e != JIM_OK) {
Jim_SetResultString(goi->interp, "protocol error", -1);
return JIM_ERR;
}if (e != JIM_OK) { ... }
Jim_SetResult(goi->interp, Jim_NewStringObj(goi->interp, p->name, -1));
}else { ... }
break;case CFG_PROTOCOL:
case CFG_FORMATTER:
if (goi->isconfigure) {
struct jim_nvp *p;
e = jim_getopt_nvp(goi, nvp_arm_tpiu_swo_bool_opts, &p);
if (e != JIM_OK)
return e;
obj->en_formatter = p->value;
}if (goi->isconfigure) { ... } else {
if (goi->argc)
goto err_no_params;
struct jim_nvp *p;
e = jim_nvp_value2name(goi->interp, nvp_arm_tpiu_swo_bool_opts, obj->en_formatter, &p);
if (e != JIM_OK) {
Jim_SetResultString(goi->interp, "formatter error", -1);
return JIM_ERR;
}if (e != JIM_OK) { ... }
Jim_SetResult(goi->interp, Jim_NewStringObj(goi->interp, p->name, -1));
}else { ... }
break;case CFG_FORMATTER:
case CFG_TRACECLKIN:
if (goi->isconfigure) {
jim_wide clk;
e = jim_getopt_wide(goi, &clk);
if (e != JIM_OK)
return e;
obj->traceclkin_freq = clk;
}if (goi->isconfigure) { ... } else {
if (goi->argc)
goto err_no_params;
Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, obj->traceclkin_freq));
}else { ... }
break;case CFG_TRACECLKIN:
case CFG_BITRATE:
if (goi->isconfigure) {
jim_wide clk;
e = jim_getopt_wide(goi, &clk);
if (e != JIM_OK)
return e;
obj->swo_pin_freq = clk;
}if (goi->isconfigure) { ... } else {
if (goi->argc)
goto err_no_params;
Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, obj->swo_pin_freq));
}else { ... }
break;case CFG_BITRATE:
case CFG_OUTFILE:
if (goi->isconfigure) {
const char *s;
e = jim_getopt_string(goi, &s, NULL);
if (e != JIM_OK)
return e;
if (s[0] == ':') {
char *end;
long port = strtol(s + 1, &end, 0);
if (port <= 0 || port > UINT16_MAX || *end != '\0') {
Jim_SetResultFormatted(goi->interp, "Invalid TCP port \'%s\'", s + 1);
return JIM_ERR;
}if (port <= 0 || port > UINT16_MAX || *end != '\0') { ... }
}if (s[0] == ':') { ... }
char *out_filename = strdup(s);
if (!out_filename) {
LOG_ERROR("Out of memory");
return JIM_ERR;
}if (!out_filename) { ... }
free(obj->out_filename);
obj->out_filename = out_filename;
}if (goi->isconfigure) { ... } else {
if (goi->argc)
goto err_no_params;
if (obj->out_filename)
Jim_SetResult(goi->interp, Jim_NewStringObj(goi->interp, obj->out_filename, -1));
}else { ... }
break;case CFG_OUTFILE:
case CFG_EVENT:
if (goi->isconfigure) {
if (goi->argc < 2) {
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name? ?EVENT-BODY?");
return JIM_ERR;
}if (goi->argc < 2) { ... }
}if (goi->isconfigure) { ... } else {
if (goi->argc != 1) {
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name?");
return JIM_ERR;
}if (goi->argc != 1) { ... }
}else { ... }
{
struct jim_nvp *p;
Jim_Obj *o;
struct arm_tpiu_swo_event_action *ea = obj->event_action;
e = jim_getopt_nvp(goi, nvp_arm_tpiu_swo_event, &p);
if (e != JIM_OK) {
jim_getopt_nvp_unknown(goi, nvp_arm_tpiu_swo_event, 1);
return e;
}if (e != JIM_OK) { ... }
while (ea) {
if (ea->event == (enum arm_tpiu_swo_event)p->value)
break;
ea = ea->next;
}while (ea) { ... }
if (goi->isconfigure) {
if (!ea) {
ea = calloc(1, sizeof(*ea));
if (!ea) {
LOG_ERROR("Out of memory");
return JIM_ERR;
}if (!ea) { ... }
ea->next = obj->event_action;
obj->event_action = ea;
}if (!ea) { ... }
if (ea->body)
Jim_DecrRefCount(ea->interp, ea->body);
ea->event = p->value;
ea->interp = goi->interp;
jim_getopt_obj(goi, &o);
ea->body = Jim_DuplicateObj(goi->interp, o);
Jim_IncrRefCount(ea->body);
}if (goi->isconfigure) { ... } else {
if (ea)
Jim_SetResult(goi->interp, Jim_DuplicateObj(goi->interp, ea->body));
}else { ... }
...}
break;case CFG_EVENT:
}switch (n->value) { ... }
}while (goi->argc > 0) { ... }
return JIM_OK;
err_no_params:
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "NO PARAMS");
return JIM_ERR;
}{ ... }
static int jim_arm_tpiu_swo_configure(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
{
struct command *c = jim_to_command(interp);
struct jim_getopt_info goi;
jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
goi.isconfigure = !strcmp(c->name, "configure");
if (goi.argc < 1) {
Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv,
"missing: -option ...");
return JIM_ERR;
}if (goi.argc < 1) { ... }
struct arm_tpiu_swo_object *obj = c->jim_handler_data;
return arm_tpiu_swo_configure(&goi, obj);
}{ ... }
static int wrap_write_u32(struct target *target, struct adiv5_ap *tpiu_ap,
target_addr_t address, uint32_t value)
{
if (transport_is_hla())
return target_write_u32(target, address, value);
else
return mem_ap_write_atomic_u32(tpiu_ap, address, value);
}{ ... }
static int wrap_read_u32(struct target *target, struct adiv5_ap *tpiu_ap,
target_addr_t address, uint32_t *value)
{
if (transport_is_hla())
return target_read_u32(target, address, value);
else
return mem_ap_read_atomic_u32(tpiu_ap, address, value);
}{ ... }
static const struct service_driver arm_tpiu_swo_service_driver = {
.name = "tpiu_swo_trace",
.new_connection_during_keep_alive_handler = NULL,
.new_connection_handler = arm_tpiu_swo_service_new_connection,
.input_handler = arm_tpiu_swo_service_input,
.connection_closed_handler = arm_tpiu_swo_service_connection_closed,
.keep_client_alive_handler = NULL,
...};
COMMAND_HANDLER(handle_arm_tpiu_swo_enable)
{
struct arm_tpiu_swo_object *obj = CMD_DATA;
uint32_t value;
int retval;
if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
if (CMD_CTX->mode == COMMAND_CONFIG) {
LOG_DEBUG("%s: enable deferred", obj->name);
obj->deferred_enable = true;
return ERROR_OK;
}if (CMD_CTX->mode == COMMAND_CONFIG) { ... }
if (obj->enabled)
return ERROR_OK;
if (transport_is_hla() && obj->spot.ap_num != 0) {
command_print(CMD,
"Invalid access port 0x%" PRIx64 ". Only AP#0 allowed with hla transport",
obj->spot.ap_num);
return ERROR_FAIL;
}if (transport_is_hla() && obj->spot.ap_num != 0) { ... }
if (!obj->traceclkin_freq) {
command_print(CMD, "Trace clock-in frequency not set");
return ERROR_FAIL;
}if (!obj->traceclkin_freq) { ... }
const bool output_external = !strcmp(obj->out_filename, "external");
if (obj->pin_protocol == TPIU_SPPR_PROTOCOL_MANCHESTER || obj->pin_protocol == TPIU_SPPR_PROTOCOL_UART) {
if (!obj->swo_pin_freq) {
if (output_external) {
command_print(CMD, "SWO pin frequency required when using external capturing");
return ERROR_FAIL;
}if (output_external) { ... }
LOG_DEBUG("SWO pin frequency not set, will be autodetected by the adapter");
}if (!obj->swo_pin_freq) { ... }
}if (obj->pin_protocol == TPIU_SPPR_PROTOCOL_MANCHESTER || obj->pin_protocol == TPIU_SPPR_PROTOCOL_UART) { ... }
struct target *target = get_current_target(CMD_CTX);
if (obj->recheck_ap_cur_target) {
if (strcmp(target_type_name(target), "cortex_m") &&
strcmp(target_type_name(target), "hla_target")) {
LOG_ERROR(MSG "Current target is not a Cortex-M nor a HLA");
return ERROR_FAIL;
}if (strcmp(target_type_name(target), "cortex_m") && strcmp(target_type_name(target), "hla_target")) { ... }
if (!target_was_examined(target)) {
LOG_ERROR(MSG "Current target not examined yet");
return ERROR_FAIL;
}if (!target_was_examined(target)) { ... }
struct cortex_m_common *cm = target_to_cm(target);
obj->recheck_ap_cur_target = false;
obj->spot.ap_num = cm->armv7m.debug_ap->ap_num;
if (obj->spot.ap_num == 0)
LOG_INFO(MSG "Confirmed TPIU %s is on AP 0", obj->name);
else
LOG_INFO(MSG "Target %s is on AP#0x%" PRIx64 ". Revised command is "
"\'tpiu create %s -dap %s -ap-num 0x%" PRIx64 "\'",
target_name(target), obj->spot.ap_num,
obj->name, adiv5_dap_name(obj->spot.dap), obj->spot.ap_num);
}if (obj->recheck_ap_cur_target) { ... }
if (!obj->ap) {
obj->ap = dap_get_ap(obj->spot.dap, obj->spot.ap_num);
if (!obj->ap) {
command_print(CMD, "Cannot get AP");
return ERROR_FAIL;
}if (!obj->ap) { ... }
}if (!obj->ap) { ... }
retval = arm_tpiu_swo_handle_event(obj, TPIU_SWO_EVENT_PRE_ENABLE);
if (retval != ERROR_OK)
return retval;
retval = wrap_read_u32(target, obj->ap, obj->spot.base + TPIU_DEVID_OFFSET, &value);
if (retval != ERROR_OK) {
command_print(CMD, "Unable to read %s", obj->name);
return retval;
}if (retval != ERROR_OK) { ... }
switch (obj->pin_protocol) {
case TPIU_SPPR_PROTOCOL_SYNC:
value = !(value & TPIU_DEVID_NOSUPPORT_SYNC);
break;case TPIU_SPPR_PROTOCOL_SYNC:
case TPIU_SPPR_PROTOCOL_UART:
value &= TPIU_DEVID_SUPPORT_UART;
break;case TPIU_SPPR_PROTOCOL_UART:
case TPIU_SPPR_PROTOCOL_MANCHESTER:
value &= TPIU_DEVID_SUPPORT_MANCHESTER;
break;case TPIU_SPPR_PROTOCOL_MANCHESTER:
default:
value = 0;default
}switch (obj->pin_protocol) { ... }
if (!value) {
struct jim_nvp *p = jim_nvp_value2name_simple(nvp_arm_tpiu_swo_protocol_opts, obj->pin_protocol);
command_print(CMD, "%s does not support protocol %s", obj->name, p->name);
return ERROR_FAIL;
}if (!value) { ... }
if (obj->pin_protocol == TPIU_SPPR_PROTOCOL_SYNC) {
retval = wrap_read_u32(target, obj->ap, obj->spot.base + TPIU_SSPSR_OFFSET, &value);
if (retval != ERROR_OK) {
command_print(CMD, "Cannot read TPIU register SSPSR");
return retval;
}if (retval != ERROR_OK) { ... }
if (!(value & BIT(obj->port_width - 1))) {
command_print(CMD, "TPIU does not support port-width of %d bits", obj->port_width);
return ERROR_FAIL;
}if (!(value & BIT(obj->port_width - 1))) { ... }
}if (obj->pin_protocol == TPIU_SPPR_PROTOCOL_SYNC) { ... }
uint16_t prescaler = 1;
unsigned int swo_pin_freq = obj->swo_pin_freq;
if (!output_external) {
if (obj->out_filename[0] == ':') {
struct arm_tpiu_swo_priv_connection *priv = malloc(sizeof(*priv));
if (!priv) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}if (!priv) { ... }
priv->obj = obj;
LOG_INFO("starting trace server for %s on %s", obj->name, &obj->out_filename[1]);
retval = add_service(&arm_tpiu_swo_service_driver, &obj->out_filename[1],
CONNECTION_LIMIT_UNLIMITED, priv);
if (retval != ERROR_OK) {
command_print(CMD, "Can't configure trace TCP port %s", &obj->out_filename[1]);
return retval;
}if (retval != ERROR_OK) { ... }
}if (obj->out_filename[0] == ':') { ... } else if (strcmp(obj->out_filename, "-")) {
obj->file = fopen(obj->out_filename, "ab");
if (!obj->file) {
command_print(CMD, "Can't open trace destination file \"%s\"", obj->out_filename);
return ERROR_FAIL;
}if (!obj->file) { ... }
}else if (strcmp(obj->out_filename, "-")) { ... }
retval = adapter_config_trace(true, obj->pin_protocol, obj->port_width,
&swo_pin_freq, obj->traceclkin_freq, &prescaler);
if (retval != ERROR_OK) {
command_print(CMD, "Failed to start adapter's trace");
arm_tpiu_swo_close_output(obj);
return retval;
}if (retval != ERROR_OK) { ... }
if (obj->pin_protocol == TPIU_SPPR_PROTOCOL_MANCHESTER || obj->pin_protocol == TPIU_SPPR_PROTOCOL_UART)
if (!swo_pin_freq) {
if (obj->swo_pin_freq)
command_print(CMD, "Adapter rejected SWO pin frequency %d Hz", obj->swo_pin_freq);
else
command_print(CMD,
"Adapter does not support auto-detection of SWO pin frequency nor a default value");
arm_tpiu_swo_close_output(obj);
return ERROR_FAIL;
}if (!swo_pin_freq) { ... }
if (obj->swo_pin_freq != swo_pin_freq)
LOG_INFO("SWO pin data rate adjusted by adapter to %d Hz", swo_pin_freq);
obj->swo_pin_freq = swo_pin_freq;
target_register_timer_callback(arm_tpiu_swo_poll_trace, 1,
TARGET_TIMER_TYPE_PERIODIC, obj);
obj->en_capture = true;
}if (!output_external) { ... } else if (obj->pin_protocol == TPIU_SPPR_PROTOCOL_MANCHESTER || obj->pin_protocol == TPIU_SPPR_PROTOCOL_UART) {
prescaler = (obj->traceclkin_freq + obj->swo_pin_freq / 2) / obj->swo_pin_freq;
if (prescaler > TPIU_ACPR_MAX_PRESCALER)
prescaler = TPIU_ACPR_MAX_PRESCALER;
swo_pin_freq = obj->traceclkin_freq / prescaler;
if (obj->swo_pin_freq != swo_pin_freq)
LOG_INFO("SWO pin data rate adjusted to %d Hz", swo_pin_freq);
obj->swo_pin_freq = swo_pin_freq;
}else if (obj->pin_protocol == TPIU_SPPR_PROTOCOL_MANCHESTER || obj->pin_protocol == TPIU_SPPR_PROTOCOL_UART) { ... }
retval = wrap_write_u32(target, obj->ap, obj->spot.base + TPIU_CSPSR_OFFSET, BIT(obj->port_width - 1));
if (retval != ERROR_OK)
goto error_exit;
retval = wrap_write_u32(target, obj->ap, obj->spot.base + TPIU_ACPR_OFFSET, prescaler - 1);
if (retval != ERROR_OK)
goto error_exit;
retval = wrap_write_u32(target, obj->ap, obj->spot.base + TPIU_SPPR_OFFSET, obj->pin_protocol);
if (retval != ERROR_OK)
goto error_exit;
retval = wrap_read_u32(target, obj->ap, obj->spot.base + TPIU_FFCR_OFFSET, &value);
if (retval != ERROR_OK)
goto error_exit;
if (obj->en_formatter)
value |= BIT(1);
else
value &= ~BIT(1);
retval = wrap_write_u32(target, obj->ap, obj->spot.base + TPIU_FFCR_OFFSET, value);
if (retval != ERROR_OK)
goto error_exit;
retval = arm_tpiu_swo_handle_event(obj, TPIU_SWO_EVENT_POST_ENABLE);
if (retval != ERROR_OK)
goto error_exit;
target_handle_event(target, TARGET_EVENT_TRACE_CONFIG);
obj->enabled = true;
return ERROR_OK;
error_exit:
command_print(CMD, "Error!");
if (obj->en_capture) {
obj->en_capture = false;
arm_tpiu_swo_close_output(obj);
target_unregister_timer_callback(arm_tpiu_swo_poll_trace, obj);
int retval1 = adapter_config_trace(false, 0, 0, NULL, 0, NULL);
if (retval1 != ERROR_OK)
command_print(CMD, "Failed to stop adapter's trace");
}if (obj->en_capture) { ... }
return retval;
}{ ... }
COMMAND_HANDLER(handle_arm_tpiu_swo_disable)
{
struct arm_tpiu_swo_object *obj = CMD_DATA;
if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
if (!obj->enabled)
return ERROR_OK;
obj->enabled = false;
arm_tpiu_swo_handle_event(obj, TPIU_SWO_EVENT_PRE_DISABLE);
if (obj->en_capture) {
obj->en_capture = false;
arm_tpiu_swo_close_output(obj);
target_unregister_timer_callback(arm_tpiu_swo_poll_trace, obj);
int retval = adapter_config_trace(false, 0, 0, NULL, 0, NULL);
if (retval != ERROR_OK) {
command_print(CMD, "Failed to stop adapter's trace");
return retval;
}if (retval != ERROR_OK) { ... }
}if (obj->en_capture) { ... }
arm_tpiu_swo_handle_event(obj, TPIU_SWO_EVENT_POST_DISABLE);
struct target *target = get_current_target(CMD_CTX);
target_handle_event(target, TARGET_EVENT_TRACE_CONFIG);
return ERROR_OK;
}{ ... }
static const struct command_registration arm_tpiu_swo_instance_command_handlers[] = {
{
.name = "configure",
.mode = COMMAND_ANY,
.jim_handler = jim_arm_tpiu_swo_configure,
.help = "configure a new TPIU/SWO for use",
.usage = "[attribute value ...]",
...},
{
.name = "cget",
.mode = COMMAND_ANY,
.jim_handler = jim_arm_tpiu_swo_configure,
.help = "returns the specified TPIU/SWO attribute",
.usage = "attribute",
...},
{
.name = "eventlist",
.mode = COMMAND_ANY,
.handler = handle_arm_tpiu_swo_event_list,
.help = "displays a table of events defined for this TPIU/SWO",
.usage = "",
...},
{
.name = "enable",
.mode = COMMAND_ANY,
.handler = handle_arm_tpiu_swo_enable,
.usage = "",
.help = "Enables the TPIU/SWO output",
...},
{
.name = "disable",
.mode = COMMAND_EXEC,
.handler = handle_arm_tpiu_swo_disable,
.usage = "",
.help = "Disables the TPIU/SWO output",
...},
COMMAND_REGISTRATION_DONE
...};
static int arm_tpiu_swo_create(Jim_Interp *interp, struct arm_tpiu_swo_object *obj)
{
struct command_context *cmd_ctx;
Jim_Cmd *cmd;
int e;
cmd_ctx = current_command_context(interp);
assert(cmd_ctx);
cmd = Jim_GetCommand(interp, Jim_NewStringObj(interp, obj->name, -1), JIM_NONE);
if (cmd) {
Jim_SetResultFormatted(interp, "cannot create TPIU object because a command with name '%s' already exists",
obj->name);
return JIM_ERR;
}if (cmd) { ... }
const struct command_registration obj_commands[] = {
{
.name = obj->name,
.mode = COMMAND_ANY,
.help = "tpiu/swo instance command group",
.usage = "",
.chain = arm_tpiu_swo_instance_command_handlers,
...},
COMMAND_REGISTRATION_DONE
...};
e = register_commands_with_data(cmd_ctx, NULL, obj_commands, obj);
if (e != ERROR_OK)
return JIM_ERR;
list_add_tail(&obj->lh, &all_tpiu_swo);
return JIM_OK;
}{ ... }
static int jim_arm_tpiu_swo_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
struct jim_getopt_info goi;
jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
if (goi.argc < 1) {
Jim_WrongNumArgs(interp, 1, argv, "name ?option option ...?");
return JIM_ERR;
}if (goi.argc < 1) { ... }
struct arm_tpiu_swo_object *obj = calloc(1, sizeof(struct arm_tpiu_swo_object));
if (!obj) {
LOG_ERROR("Out of memory");
return JIM_ERR;
}if (!obj) { ... }
INIT_LIST_HEAD(&obj->connections);
adiv5_mem_ap_spot_init(&obj->spot);
obj->spot.base = TPIU_SWO_DEFAULT_BASE;
obj->port_width = 1;
obj->out_filename = strdup("external");
if (!obj->out_filename) {
LOG_ERROR("Out of memory");
goto err_exit;
}if (!obj->out_filename) { ... }
Jim_Obj *n;
jim_getopt_obj(&goi, &n);
obj->name = strdup(Jim_GetString(n, NULL));
if (!obj->name) {
LOG_ERROR("Out of memory");
goto err_exit;
}if (!obj->name) { ... }
goi.isconfigure = 1;
int e = arm_tpiu_swo_configure(&goi, obj);
if (e != JIM_OK)
goto err_exit;
if (!obj->spot.dap || obj->spot.ap_num == DP_APSEL_INVALID) {
Jim_SetResultString(goi.interp, "-dap and -ap-num required when creating TPIU", -1);
goto err_exit;
}if (!obj->spot.dap || obj->spot.ap_num == DP_APSEL_INVALID) { ... }
e = arm_tpiu_swo_create(goi.interp, obj);
if (e != JIM_OK)
goto err_exit;
return JIM_OK;
err_exit:
free(obj->name);
free(obj->out_filename);
free(obj);
return JIM_ERR;
}{ ... }
COMMAND_HANDLER(handle_arm_tpiu_swo_names)
{
struct arm_tpiu_swo_object *obj;
if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
list_for_each_entry(obj, &all_tpiu_swo, lh)
command_print(CMD, "%s", obj->name);
return ERROR_OK;
}{ ... }
COMMAND_HANDLER(handle_arm_tpiu_swo_init)
{
struct arm_tpiu_swo_object *obj;
int retval = ERROR_OK;
if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
list_for_each_entry(obj, &all_tpiu_swo, lh) {
if (!obj->deferred_enable)
continue;
LOG_DEBUG("%s: running enable during init", obj->name);
int retval2 = command_run_linef(CMD_CTX, "%s enable", obj->name);
if (retval2 != ERROR_OK)
retval = retval2;
}list_for_each_entry (obj, &all_tpiu_swo, lh) { ... }
return retval;
}{ ... }
COMMAND_HANDLER(handle_tpiu_deprecated_config_command)
{
struct target *target = get_current_target(CMD_CTX);
struct arm_tpiu_swo_object *obj = NULL;
int retval;
if (strcmp(target_type_name(target), "cortex_m") &&
strcmp(target_type_name(target), "hla_target")) {
LOG_ERROR(MSG "Current target is not a Cortex-M nor a HLA");
return ERROR_FAIL;
}if (strcmp(target_type_name(target), "cortex_m") && strcmp(target_type_name(target), "hla_target")) { ... }
if (!list_empty(&all_tpiu_swo)) {
obj = list_first_entry(&all_tpiu_swo, typeof(*obj), lh);
LOG_INFO(MSG "Using %s", obj->name);
}if (!list_empty(&all_tpiu_swo)) { ... } else {
struct cortex_m_common *cm = target_to_cm(target);
struct adiv5_private_config *pc = target->private_config;
struct adiv5_dap *dap = pc->dap;
uint64_t ap_num = pc->ap_num;
bool set_recheck_ap_cur_target = false;
LOG_INFO(MSG "Adding a TPIU \'%s.tpiu\' in the configuration", target_name(target));
if (ap_num == DP_APSEL_INVALID && transport_is_hla())
ap_num = 0;
if (ap_num == DP_APSEL_INVALID && target_was_examined(target))
ap_num = cm->armv7m.debug_ap->ap_num;
if (ap_num == DP_APSEL_INVALID) {
LOG_INFO(MSG "Target %s uses AP autodetection. Adding TPIU on AP 0; can be revised later",
target_name(target));
ap_num = 0;
set_recheck_ap_cur_target = true;
}if (ap_num == DP_APSEL_INVALID) { ... }
LOG_INFO(MSG "Running: \'tpiu create %s.tpiu -dap %s -ap-num 0x%" PRIx64 "\'",
target_name(target), adiv5_dap_name(dap), ap_num);
retval = command_run_linef(CMD_CTX, "tpiu create %s.tpiu -dap %s -ap-num 0x%" PRIx64,
target_name(target), adiv5_dap_name(dap), ap_num);
if (retval != ERROR_OK)
return retval;
obj = list_first_entry(&all_tpiu_swo, typeof(*obj), lh);
if (set_recheck_ap_cur_target)
obj->recheck_ap_cur_target = true;
}else { ... }
unsigned int cmd_idx = 0;
if (cmd_idx == CMD_ARGC)
return ERROR_COMMAND_SYNTAX_ERROR;
if (!strcmp(CMD_ARGV[cmd_idx], "disable")) {
if (CMD_ARGC != cmd_idx + 1)
return ERROR_COMMAND_SYNTAX_ERROR;
LOG_INFO(MSG "Running: \'%s disable\'", obj->name);
return command_run_linef(CMD_CTX, "%s disable", obj->name);
}if (!strcmp(CMD_ARGV[cmd_idx], "disable")) { ... }
const char *output = NULL;
const char *protocol;
const char *formatter = NULL;
const char *port_width = NULL;
const char *trace_clk;
const char *pin_clk = NULL;
if (!strcmp(CMD_ARGV[cmd_idx], "internal")) {
cmd_idx++;
if (cmd_idx == CMD_ARGC)
return ERROR_COMMAND_SYNTAX_ERROR;
output = CMD_ARGV[cmd_idx];
}if (!strcmp(CMD_ARGV[cmd_idx], "internal")) { ... } else if (strcmp(CMD_ARGV[cmd_idx], "external"))
return ERROR_COMMAND_SYNTAX_ERROR;
cmd_idx++;
if (cmd_idx == CMD_ARGC)
return ERROR_COMMAND_SYNTAX_ERROR;
if (!strcmp(CMD_ARGV[cmd_idx], "sync")) {
protocol = CMD_ARGV[cmd_idx];
cmd_idx++;
if (cmd_idx == CMD_ARGC)
return ERROR_COMMAND_SYNTAX_ERROR;
port_width = CMD_ARGV[cmd_idx];
}if (!strcmp(CMD_ARGV[cmd_idx], "sync")) { ... } else {
if (strcmp(CMD_ARGV[cmd_idx], "manchester") && strcmp(CMD_ARGV[cmd_idx], "uart"))
return ERROR_COMMAND_SYNTAX_ERROR;
protocol = CMD_ARGV[cmd_idx];
cmd_idx++;
if (cmd_idx == CMD_ARGC)
return ERROR_COMMAND_SYNTAX_ERROR;
formatter = CMD_ARGV[cmd_idx];
}else { ... }
cmd_idx++;
if (cmd_idx == CMD_ARGC)
return ERROR_COMMAND_SYNTAX_ERROR;
trace_clk = CMD_ARGV[cmd_idx];
cmd_idx++;
if (cmd_idx != CMD_ARGC) {
pin_clk = CMD_ARGV[cmd_idx];
cmd_idx++;
}if (cmd_idx != CMD_ARGC) { ... }
if (cmd_idx != CMD_ARGC)
return ERROR_COMMAND_SYNTAX_ERROR;
LOG_INFO(MSG "Running: \'%s configure -protocol %s -traceclk %s" "%s%s" "%s%s" "%s%s" "%s%s\'",
obj->name, protocol, trace_clk,
pin_clk ? " -pin-freq " : "", pin_clk ? pin_clk : "",
output ? " -output " : "", output ? output : "",
formatter ? " -formatter " : "", formatter ? formatter : "",
port_width ? " -port-width " : "", port_width ? port_width : "");
retval = command_run_linef(CMD_CTX,
"%s configure -protocol %s -traceclk %s" "%s%s" "%s%s" "%s%s" "%s%s",
obj->name, protocol, trace_clk,
pin_clk ? " -pin-freq " : "", pin_clk ? pin_clk : "",
output ? " -output " : "", output ? output : "",
formatter ? " -formatter " : "", formatter ? formatter : "",
port_width ? " -port-width " : "", port_width ? port_width : "");
if (retval != ERROR_OK)
return retval;
LOG_INFO(MSG "Running: \'%s enable\'", obj->name);
retval = command_run_linef(CMD_CTX, "%s enable", obj->name);
if (retval != ERROR_OK)
return retval;
return ERROR_OK;
}{ ... }
static const struct command_registration arm_tpiu_deprecated_subcommand_handlers[] = {
{
.name = "config",
.handler = handle_tpiu_deprecated_config_command,
.mode = COMMAND_ANY,
.help = "Configure TPIU features, DEPRECATED, use \'tpiu create\'",
.usage = "(disable | "
"((external | internal (<filename> | <:port> | -)) "
"(sync <port width> | ((manchester | uart) <formatter enable>)) "
"<TRACECLKIN freq> [<trace freq>]))",
...},
COMMAND_REGISTRATION_DONE
...};
const struct command_registration arm_tpiu_deprecated_command_handlers[] = {
{
.name = "tpiu",
.chain = arm_tpiu_deprecated_subcommand_handlers,
.usage = "",
.help = "tpiu command group",
...},
COMMAND_REGISTRATION_DONE
...};
static const struct command_registration arm_tpiu_swo_subcommand_handlers[] = {
{
.name = "create",
.mode = COMMAND_ANY,
.jim_handler = jim_arm_tpiu_swo_create,
.usage = "name [-dap dap] [-ap-num num] [-baseaddr baseaddr]",
.help = "Creates a new TPIU or SWO object",
...},
{
.name = "names",
.mode = COMMAND_ANY,
.handler = handle_arm_tpiu_swo_names,
.usage = "",
.help = "Lists all registered TPIU and SWO objects by name",
...},
{
.name = "init",
.mode = COMMAND_EXEC,
.handler = handle_arm_tpiu_swo_init,
.usage = "",
.help = "Initialize TPIU and SWO",
...},
COMMAND_REGISTRATION_DONE
...};
static const struct command_registration arm_tpiu_swo_command_handlers[] = {
{
.name = "tpiu",
.chain = arm_tpiu_swo_subcommand_handlers,
.usage = "",
.help = "tpiu command group",
...},
{
.name = "swo",
.chain = arm_tpiu_swo_subcommand_handlers,
.usage = "",
.help = "swo command group",
...},
COMMAND_REGISTRATION_DONE
...};
int arm_tpiu_swo_register_commands(struct command_context *cmd_ctx)
{
return register_commands(cmd_ctx, NULL, arm_tpiu_swo_command_handlers);
}{ ... }