1
2
3
7
8
9
10
11
12
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
67
68
72
73
74
75
76
77
78
79
80
83
84
85
86
87
88
89
90
91
92
93
94
95
97
102
103
108
109
110
111
116
117
118
119
120
121
122
123
124
125
126
131
132
133
134
135
136
137
138
139
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
180
181
182
185
186
187
188
199
200
201
202
203
204
205
206
207
212
213
216
229
230
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
266
267
268
269
270
271
272
273
274
275
276
277
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
307
308
309
310
317
318
319
320
321
322
323
330
331
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
385
386
387
388
389
390
391
392
393
397
398
405
406
407
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
436
437
438
443
444
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
517
521
522
523
524
525
526
527
528
529
530
531
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
558
562
563
564
565
566
567
568
569
570
571
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
612
613
614
615
633
634
652
653
671
672
690
691
709
710
728
729
747
748
766
767
783
784
802
803
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
860
861
879
880
881
882
883
884
885
886
887
888
893
899
906
907
908
909
910
911
912
913
920
927
934
941
948
955
962
969
976
983
984
985
986
987
988
989
990
991
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
/* ... */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "assert.h"
#include <target/target.h>
#include <target/target_type.h>
#include <target/smp.h>
#include <target/semihosting_common.h>
#include "esp_xtensa_smp.h"
#include "esp_xtensa_semihosting.h"
#include "esp_algorithm.h"
8 includes
/* ... */
/* ... */
#define ESP_XTENSA_SMP_EXAMINE_OTHER_CORES 5
static int esp_xtensa_smp_update_halt_gdb(struct target *target, bool *need_resume);
static inline struct esp_xtensa_smp_common *target_to_esp_xtensa_smp(struct target *target)
{
return container_of(target->arch_info, struct esp_xtensa_smp_common, esp_xtensa);
}{ ... }
int esp_xtensa_smp_assert_reset(struct target *target)
{
return ERROR_OK;
}{ ... }
int esp_xtensa_smp_deassert_reset(struct target *target)
{
LOG_TARGET_DEBUG(target, "begin");
int ret = xtensa_deassert_reset(target);
if (ret != ERROR_OK)
return ret;
/* ... */
if (target->smp && !target_was_examined(target))
ret = xtensa_examine(target);
return ret;
}{ ... }
int esp_xtensa_smp_soft_reset_halt(struct target *target)
{
int res;
struct target_list *head;
struct esp_xtensa_smp_common *esp_xtensa_smp = target_to_esp_xtensa_smp(target);
LOG_TARGET_DEBUG(target, "begin");
/* ... */
if (target->smp) {
head = list_first_entry(target->smp_targets, struct target_list, lh);
if (head->target != target)
return ERROR_OK;
}if (target->smp) { ... }
if (esp_xtensa_smp->chip_ops->reset) {
res = esp_xtensa_smp->chip_ops->reset(target);
if (res != ERROR_OK)
return res;
}if (esp_xtensa_smp->chip_ops->reset) { ... }
if (!target->smp)
return xtensa_assert_reset(target);
foreach_smp_target(head, target->smp_targets) {
res = xtensa_assert_reset(head->target);
if (res != ERROR_OK)
return res;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}{ ... }
int esp_xtensa_smp_on_halt(struct target *target)
{
struct target_list *head;
if (!target->smp)
return esp_xtensa_on_halt(target);
foreach_smp_target(head, target->smp_targets) {
int res = esp_xtensa_on_halt(head->target);
if (res != ERROR_OK)
return res;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}{ ... }
static struct target *get_halted_esp_xtensa_smp(struct target *target, int32_t coreid)
{
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
if ((curr->coreid == coreid) && (curr->state == TARGET_HALTED))
return curr;
}foreach_smp_target (head, target->smp_targets) { ... }
return target;
}{ ... }
int esp_xtensa_smp_poll(struct target *target)
{
enum target_state old_state = target->state;
struct esp_xtensa_smp_common *esp_xtensa_smp = target_to_esp_xtensa_smp(target);
struct esp_xtensa_common *esp_xtensa = target_to_esp_xtensa(target);
uint32_t old_dbg_stubs_base = esp_xtensa->esp.dbg_stubs.base;
struct target_list *head;
struct target *curr;
bool other_core_resume_req = false;
if (target->state == TARGET_HALTED && target->smp && target->gdb_service && !target->gdb_service->target) {
target->gdb_service->target = get_halted_esp_xtensa_smp(target, target->gdb_service->core[1]);
LOG_INFO("Switch GDB target to '%s'", target_name(target->gdb_service->target));
if (esp_xtensa_smp->chip_ops->on_halt)
esp_xtensa_smp->chip_ops->on_halt(target);
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
return ERROR_OK;
}if (target->state == TARGET_HALTED && target->smp && target->gdb_service && !target->gdb_service->target) { ... }
int ret = esp_xtensa_poll(target);
if (ret != ERROR_OK)
return ret;
if (esp_xtensa->esp.dbg_stubs.base && old_dbg_stubs_base != esp_xtensa->esp.dbg_stubs.base) {
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
if (curr == target)
continue;
target_to_esp_xtensa(curr)->esp.dbg_stubs.base = esp_xtensa->esp.dbg_stubs.base;
}foreach_smp_target (head, target->smp_targets) { ... }
}if (esp_xtensa->esp.dbg_stubs.base && old_dbg_stubs_base != esp_xtensa->esp.dbg_stubs.base) { ... }
if (target->smp) {
if (target->state == TARGET_RESET) {
esp_xtensa_smp->examine_other_cores = ESP_XTENSA_SMP_EXAMINE_OTHER_CORES;
}if (target->state == TARGET_RESET) { ... } else if (esp_xtensa_smp->examine_other_cores > 0 &&
(target->state == TARGET_RUNNING || target->state == TARGET_HALTED)) {
LOG_TARGET_DEBUG(target, "Check for unexamined cores after reset");
bool all_examined = true;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
if (curr == target)
continue;
if (!target_was_examined(curr)) {
if (target_examine_one(curr) != ERROR_OK) {
LOG_DEBUG("Failed to examine!");
all_examined = false;
}if (target_examine_one(curr) != ERROR_OK) { ... }
}if (!target_was_examined(curr)) { ... }
}foreach_smp_target (head, target->smp_targets) { ... }
if (all_examined)
esp_xtensa_smp->examine_other_cores = 0;
else
esp_xtensa_smp->examine_other_cores--;
}else if (esp_xtensa_smp->examine_other_cores > 0 && (target->state == TARGET_RUNNING || target->state == TARGET_HALTED)) { ... }
}if (target->smp) { ... }
if (old_state != TARGET_HALTED && target->state == TARGET_HALTED) {
if (target->smp) {
ret = esp_xtensa_smp_update_halt_gdb(target, &other_core_resume_req);
if (ret != ERROR_OK)
return ret;
}if (target->smp) { ... }
if (old_state == TARGET_DEBUG_RUNNING) {
target_call_event_callbacks(target, TARGET_EVENT_DEBUG_HALTED);
}if (old_state == TARGET_DEBUG_RUNNING) { ... } else {
if (esp_xtensa_semihosting(target, &ret) == SEMIHOSTING_HANDLED) {
if (ret == ERROR_OK && esp_xtensa->semihost.need_resume &&
!esp_xtensa_smp->other_core_does_resume) {
esp_xtensa->semihost.need_resume = false;
ret = target_resume(target, 1, 0, 1, 0);
if (ret != ERROR_OK) {
LOG_ERROR("Failed to resume target");
return ret;
}if (ret != ERROR_OK) { ... }
}if (ret == ERROR_OK && esp_xtensa->semihost.need_resume && !esp_xtensa_smp->other_core_does_resume) { ... }
return ret;
}if (esp_xtensa_semihosting(target, &ret) == SEMIHOSTING_HANDLED) { ... }
if (target->smp && other_core_resume_req) {
ret = target_resume(target, 1, 0, 1, 0);
if (ret != ERROR_OK) {
LOG_ERROR("Failed to resume target");
return ret;
}if (ret != ERROR_OK) { ... }
return ERROR_OK;
}if (target->smp && other_core_resume_req) { ... }
if (esp_xtensa_smp->chip_ops->on_halt)
esp_xtensa_smp->chip_ops->on_halt(target);
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
}else { ... }
}if (old_state != TARGET_HALTED && target->state == TARGET_HALTED) { ... }
return ERROR_OK;
}{ ... }
static int esp_xtensa_smp_update_halt_gdb(struct target *target, bool *need_resume)
{
struct esp_xtensa_smp_common *esp_xtensa_smp;
struct target *gdb_target = NULL;
struct target_list *head;
struct target *curr;
int ret = ERROR_OK;
*need_resume = false;
if (target->gdb_service && target->gdb_service->target)
LOG_DEBUG("GDB target '%s'", target_name(target->gdb_service->target));
if (target->gdb_service && target->gdb_service->core[0] == -1) {
target->gdb_service->target = target;
target->gdb_service->core[0] = target->coreid;
LOG_INFO("Set GDB target to '%s'", target_name(target));
}if (target->gdb_service && target->gdb_service->core[0] == -1) { ... }
if (target->gdb_service)
gdb_target = target->gdb_service->target;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
LOG_DEBUG("Check target '%s'", target_name(curr));
if (curr == target)
continue;
if (!target_was_examined(curr)) {
curr->state = TARGET_HALTED;
continue;
}if (!target_was_examined(curr)) { ... }
if (curr->state == TARGET_HALTED)
continue;
if (curr == gdb_target)
continue;
LOG_DEBUG("Poll target '%s'", target_name(curr));
esp_xtensa_smp = target_to_esp_xtensa_smp(curr);
esp_xtensa_smp->other_core_does_resume = true;
curr->smp = 0;
if (esp_xtensa_smp->chip_ops->poll)
ret = esp_xtensa_smp->chip_ops->poll(curr);
else
ret = esp_xtensa_smp_poll(curr);
curr->smp = 1;
if (ret != ERROR_OK)
return ret;
esp_xtensa_smp->other_core_does_resume = false;
struct esp_xtensa_common *curr_esp_xtensa = target_to_esp_xtensa(curr);
if (curr_esp_xtensa->semihost.need_resume) {
curr_esp_xtensa->semihost.need_resume = false;
*need_resume = true;
}if (curr_esp_xtensa->semihost.need_resume) { ... }
}foreach_smp_target (head, target->smp_targets) { ... }
if (gdb_target && gdb_target != target) {
esp_xtensa_smp = target_to_esp_xtensa_smp(gdb_target);
if (esp_xtensa_smp->chip_ops->poll)
ret = esp_xtensa_smp->chip_ops->poll(gdb_target);
else
ret = esp_xtensa_smp_poll(gdb_target);
}if (gdb_target && gdb_target != target) { ... }
LOG_DEBUG("exit");
return ret;
}{ ... }
static inline int esp_xtensa_smp_smpbreak_disable(struct target *target, uint32_t *smp_break)
{
int res = xtensa_smpbreak_get(target, smp_break);
if (res != ERROR_OK)
return res;
return xtensa_smpbreak_set(target, 0);
}{ ... }
static inline int esp_xtensa_smp_smpbreak_restore(struct target *target, uint32_t smp_break)
{
return xtensa_smpbreak_set(target, smp_break);
}{ ... }
static int esp_xtensa_smp_resume_cores(struct target *target,
int handle_breakpoints,
int debug_execution)
{
struct target_list *head;
struct target *curr;
LOG_TARGET_DEBUG(target, "begin");
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
if ((curr != target) && (curr->state != TARGET_RUNNING) && target_was_examined(curr)) {
curr->smp = 0;
int res = esp_xtensa_smp_resume(curr, 1, 0, handle_breakpoints, debug_execution);
curr->smp = 1;
if (res != ERROR_OK)
return res;
}if ((curr != target) && (curr->state != TARGET_RUNNING) && target_was_examined(curr)) { ... }
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}{ ... }
int esp_xtensa_smp_resume(struct target *target,
int current,
target_addr_t address,
int handle_breakpoints,
int debug_execution)
{
int res;
uint32_t smp_break;
xtensa_smpbreak_get(target, &smp_break);
LOG_TARGET_DEBUG(target, "smp_break=0x%" PRIx32, smp_break);
if ((target->smp) && (target->gdb_service) && (target->gdb_service->core[1] != -1)) {
target->gdb_service->target = NULL;
target->gdb_service->core[0] = target->gdb_service->core[1];
LOG_TARGET_DEBUG(target, "Fake resume");
target_call_event_callbacks(target, TARGET_EVENT_RESUMED);
return ERROR_OK;
}if ((target->smp) && (target->gdb_service) && (target->gdb_service->core[1] != -1)) { ... }
/* ... */
res = esp_xtensa_smp_smpbreak_disable(target, &smp_break);
if (res != ERROR_OK)
return res;
res = xtensa_prepare_resume(target, current, address, handle_breakpoints, debug_execution);
int ret = esp_xtensa_smp_smpbreak_restore(target, smp_break);
if (ret != ERROR_OK)
return ret;
if (res != ERROR_OK) {
LOG_TARGET_ERROR(target, "Failed to prepare for resume!");
return res;
}if (res != ERROR_OK) { ... }
if (target->smp) {
if (target->gdb_service)
target->gdb_service->core[0] = -1;
res = esp_xtensa_smp_resume_cores(target, handle_breakpoints, debug_execution);
if (res != ERROR_OK)
return res;
}if (target->smp) { ... }
res = xtensa_do_resume(target);
if (res != ERROR_OK) {
LOG_TARGET_ERROR(target, "Failed to resume!");
return res;
}if (res != ERROR_OK) { ... }
target->debug_reason = DBG_REASON_NOTHALTED;
if (!debug_execution)
target->state = TARGET_RUNNING;
else
target->state = TARGET_DEBUG_RUNNING;
target_call_event_callbacks(target, TARGET_EVENT_RESUMED);
return ERROR_OK;
}{ ... }
int esp_xtensa_smp_step(struct target *target,
int current,
target_addr_t address,
int handle_breakpoints)
{
int res;
uint32_t smp_break = 0;
struct esp_xtensa_smp_common *esp_xtensa_smp = target_to_esp_xtensa_smp(target);
if (target->smp) {
res = esp_xtensa_smp_smpbreak_disable(target, &smp_break);
if (res != ERROR_OK)
return res;
}if (target->smp) { ... }
res = xtensa_step(target, current, address, handle_breakpoints);
if (res == ERROR_OK) {
if (esp_xtensa_smp->chip_ops->on_halt)
esp_xtensa_smp->chip_ops->on_halt(target);
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
}if (res == ERROR_OK) { ... }
if (target->smp) {
int ret = esp_xtensa_smp_smpbreak_restore(target, smp_break);
if (ret != ERROR_OK)
return ret;
}if (target->smp) { ... }
return res;
}{ ... }
int esp_xtensa_smp_watchpoint_add(struct target *target, struct watchpoint *watchpoint)
{
int res = xtensa_watchpoint_add(target, watchpoint);
if (res != ERROR_OK)
return res;
if (!target->smp)
return ERROR_OK;
struct target_list *head;
foreach_smp_target(head, target->smp_targets) {
struct target *curr = head->target;
if (curr == target || !target_was_examined(curr))
continue;
/* ... */
curr->smp = 0;
res = watchpoint_add(curr, watchpoint->address, watchpoint->length,
watchpoint->rw, watchpoint->value, watchpoint->mask);
curr->smp = 1;
if (res != ERROR_OK)
return res;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}{ ... }
int esp_xtensa_smp_watchpoint_remove(struct target *target, struct watchpoint *watchpoint)
{
int res = xtensa_watchpoint_remove(target, watchpoint);
if (res != ERROR_OK)
return res;
if (!target->smp)
return ERROR_OK;
struct target_list *head;
foreach_smp_target(head, target->smp_targets) {
struct target *curr = head->target;
if (curr == target)
continue;
curr->smp = 0;
watchpoint_remove(curr, watchpoint->address);
curr->smp = 1;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}{ ... }
int esp_xtensa_smp_run_func_image(struct target *target, struct esp_algorithm_run_data *run, uint32_t num_args, ...)
{
struct target *run_target = target;
struct target_list *head;
va_list ap;
uint32_t smp_break = 0;
int res;
if (target->smp) {
foreach_smp_target(head, target->smp_targets) {
run_target = head->target;
if (target_was_examined(run_target) && run_target->state == TARGET_HALTED)
break;
}foreach_smp_target (head, target->smp_targets) { ... }
if (!head) {
LOG_ERROR("Failed to find HALTED core!");
return ERROR_FAIL;
}if (!head) { ... }
res = esp_xtensa_smp_smpbreak_disable(run_target, &smp_break);
if (res != ERROR_OK)
return res;
}if (target->smp) { ... }
va_start(ap, num_args);
int algo_res = esp_algorithm_run_func_image_va(run_target, run, num_args, ap);
va_end(ap);
if (target->smp) {
res = esp_xtensa_smp_smpbreak_restore(run_target, smp_break);
if (res != ERROR_OK)
return res;
}if (target->smp) { ... }
return algo_res;
}{ ... }
int esp_xtensa_smp_run_onboard_func(struct target *target,
struct esp_algorithm_run_data *run,
uint32_t func_addr,
uint32_t num_args,
...)
{
struct target *run_target = target;
struct target_list *head;
va_list ap;
uint32_t smp_break = 0;
int res;
if (target->smp) {
foreach_smp_target(head, target->smp_targets) {
run_target = head->target;
if (target_was_examined(run_target) && run_target->state == TARGET_HALTED)
break;
}foreach_smp_target (head, target->smp_targets) { ... }
if (!head) {
LOG_ERROR("Failed to find HALTED core!");
return ERROR_FAIL;
}if (!head) { ... }
res = esp_xtensa_smp_smpbreak_disable(run_target, &smp_break);
if (res != ERROR_OK)
return res;
}if (target->smp) { ... }
va_start(ap, num_args);
int algo_res = esp_algorithm_run_onboard_func_va(run_target, run, func_addr, num_args, ap);
va_end(ap);
if (target->smp) {
res = esp_xtensa_smp_smpbreak_restore(run_target, smp_break);
if (res != ERROR_OK)
return res;
}if (target->smp) { ... }
return algo_res;
}{ ... }
int esp_xtensa_smp_init_arch_info(struct target *target,
struct esp_xtensa_smp_common *esp_xtensa_smp,
struct xtensa_debug_module_config *dm_cfg,
const struct esp_xtensa_smp_chip_ops *chip_ops,
const struct esp_semihost_ops *semihost_ops)
{
int ret = esp_xtensa_init_arch_info(target, &esp_xtensa_smp->esp_xtensa, dm_cfg, semihost_ops);
if (ret != ERROR_OK)
return ret;
esp_xtensa_smp->chip_ops = chip_ops;
esp_xtensa_smp->examine_other_cores = ESP_XTENSA_SMP_EXAMINE_OTHER_CORES;
return ERROR_OK;
}{ ... }
int esp_xtensa_smp_target_init(struct command_context *cmd_ctx, struct target *target)
{
int ret = esp_xtensa_target_init(cmd_ctx, target);
if (ret != ERROR_OK)
return ret;
if (target->smp) {
struct target_list *head;
foreach_smp_target(head, target->smp_targets) {
struct target *curr = head->target;
ret = esp_xtensa_semihosting_init(curr);
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
}if (target->smp) { ... } else {
ret = esp_xtensa_semihosting_init(target);
if (ret != ERROR_OK)
return ret;
}else { ... }
return ERROR_OK;
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_xtdef)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_xtdef_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_xtdef_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_xtopt)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_xtopt_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_xtopt_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_xtmem)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_xtmem_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_xtmem_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_xtmpu)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_xtmpu_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_xtmpu_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_xtmmu)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_xtmmu_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_xtmmu_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_xtreg)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_xtreg_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_xtreg_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_xtregfmt)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_xtregfmt_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_xtregfmt_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_permissive_mode)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_permissive_mode_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_permissive_mode_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_smpbreak)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_smpbreak_do, curr);
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_smpbreak_do, target);
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_mask_interrupts)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_mask_interrupts_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_mask_interrupts_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_perfmon_enable)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp && CMD_ARGC > 0) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_perfmon_enable_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp && CMD_ARGC > 0) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_perfmon_enable_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_perfmon_dump)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
LOG_TARGET_INFO(curr, ":");
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_perfmon_dump_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_perfmon_dump_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_tracestart)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_tracestart_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_tracestart_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_tracestop)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp) {
struct target_list *head;
struct target *curr;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_tracestop_do,
target_to_xtensa(curr));
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_tracestop_do,
target_to_xtensa(target));
}{ ... }
COMMAND_HANDLER(esp_xtensa_smp_cmd_tracedump)
{
struct target *target = get_current_target(CMD_CTX);
if (target->smp) {
struct target_list *head;
struct target *curr;
int32_t cores_max_id = 0;
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
if (cores_max_id < curr->coreid)
cores_max_id = curr->coreid;
}foreach_smp_target (head, target->smp_targets) { ... }
if (CMD_ARGC < ((uint32_t)cores_max_id + 1)) {
command_print(CMD,
"Need %d filenames to dump to as output!",
cores_max_id + 1);
return ERROR_FAIL;
}if (CMD_ARGC < ((uint32_t)cores_max_id + 1)) { ... }
foreach_smp_target(head, target->smp_targets) {
curr = head->target;
int ret = CALL_COMMAND_HANDLER(xtensa_cmd_tracedump_do,
target_to_xtensa(curr), CMD_ARGV[curr->coreid]);
if (ret != ERROR_OK)
return ret;
}foreach_smp_target (head, target->smp_targets) { ... }
return ERROR_OK;
}if (target->smp) { ... }
return CALL_COMMAND_HANDLER(xtensa_cmd_tracedump_do,
target_to_xtensa(target), CMD_ARGV[0]);
}{ ... }
const struct command_registration esp_xtensa_smp_xtensa_command_handlers[] = {
{
.name = "xtdef",
.handler = esp_xtensa_smp_cmd_xtdef,
.mode = COMMAND_CONFIG,
.help = "Configure Xtensa core type",
.usage = "<type>",
...},
{
.name = "xtopt",
.handler = esp_xtensa_smp_cmd_xtopt,
.mode = COMMAND_CONFIG,
.help = "Configure Xtensa core option",
.usage = "<name> <value>",
...},
{
.name = "xtmem",
.handler = esp_xtensa_smp_cmd_xtmem,
.mode = COMMAND_CONFIG,
.help = "Configure Xtensa memory/cache option",
.usage = "<type> [parameters]",
...},
{
.name = "xtmmu",
.handler = esp_xtensa_smp_cmd_xtmmu,
.mode = COMMAND_CONFIG,
.help = "Configure Xtensa MMU option",
.usage = "<NIREFILLENTRIES> <NDREFILLENTRIES> <IVARWAY56> <DVARWAY56>",
...},
{
.name = "xtmpu",
.handler = esp_xtensa_smp_cmd_xtmpu,
.mode = COMMAND_CONFIG,
.help = "Configure Xtensa MPU option",
.usage = "<num FG seg> <min seg size> <lockable> <executeonly>",
...},
{
.name = "xtreg",
.handler = esp_xtensa_smp_cmd_xtreg,
.mode = COMMAND_CONFIG,
.help = "Configure Xtensa register",
.usage = "<regname> <regnum>",
...},
{
.name = "xtregs",
.handler = esp_xtensa_smp_cmd_xtreg,
.mode = COMMAND_CONFIG,
.help = "Configure number of Xtensa registers",
.usage = "<numregs>",
...},
{
.name = "xtregfmt",
.handler = esp_xtensa_smp_cmd_xtregfmt,
.mode = COMMAND_CONFIG,
.help = "Configure format of Xtensa register map",
.usage = "<numgregs>",
...},
{
.name = "set_permissive",
.handler = esp_xtensa_smp_cmd_permissive_mode,
.mode = COMMAND_ANY,
.help = "When set to 1, enable Xtensa permissive mode (less client-side checks)",
.usage = "[0|1]",
...},
{
.name = "maskisr",
.handler = esp_xtensa_smp_cmd_mask_interrupts,
.mode = COMMAND_ANY,
.help = "mask Xtensa interrupts at step",
.usage = "['on'|'off']",
...},
{
.name = "smpbreak",
.handler = esp_xtensa_smp_cmd_smpbreak,
.mode = COMMAND_ANY,
.help = "Set the way the CPU chains OCD breaks",
.usage =
"[none|breakinout|runstall] | [BreakIn] [BreakOut] [RunStallIn] [DebugModeOut]",
...},
{
.name = "perfmon_enable",
.handler = esp_xtensa_smp_cmd_perfmon_enable,
.mode = COMMAND_EXEC,
.help = "Enable and start performance counter",
.usage = "<counter_id> <select> [mask] [kernelcnt] [tracelevel]",
...},
{
.name = "perfmon_dump",
.handler = esp_xtensa_smp_cmd_perfmon_dump,
.mode = COMMAND_EXEC,
.help =
"Dump performance counter value. If no argument specified, dumps all counters.",
.usage = "[counter_id]",
...},
{
.name = "tracestart",
.handler = esp_xtensa_smp_cmd_tracestart,
.mode = COMMAND_EXEC,
.help =
"Tracing: Set up and start a trace. Optionally set stop trigger address and amount of data captured after.",
.usage = "[pc <pcval>/[maskbitcount]] [after <n> [ins|words]]",
...},
{
.name = "tracestop",
.handler = esp_xtensa_smp_cmd_tracestop,
.mode = COMMAND_EXEC,
.help = "Tracing: Stop current trace as started by the tracestart command",
.usage = "",
...},
{
.name = "tracedump",
.handler = esp_xtensa_smp_cmd_tracedump,
.mode = COMMAND_EXEC,
.help = "Tracing: Dump trace memory to a files. One file per core.",
.usage = "<outfile1> <outfile2>",
...},
COMMAND_REGISTRATION_DONE
...};
const struct command_registration esp_xtensa_smp_command_handlers[] = {
{
.name = "xtensa",
.usage = "",
.chain = esp_xtensa_smp_xtensa_command_handlers,
...},
COMMAND_REGISTRATION_DONE
...};