60 #define DEFAULT_HALT_TIMEOUT 5000 67 int argc, Jim_Obj *
const *argv);
69 int argc, Jim_Obj *
const *argv);
74 int fileio_errno,
bool ctrl_c);
157 static LIST_HEAD(target_reset_callback_list);
158 static LIST_HEAD(target_trace_callback_list);
168 { .name =
NULL, .value = -1 }
183 { .value = -1, .name =
NULL }
237 { .name =
NULL, .value = -1 }
246 { .name =
NULL, .value = -1 },
259 { .name =
NULL, .value = -1 },
267 { .name =
NULL, .value = -1 },
275 { .name =
NULL, .value = -1 },
286 cp =
"(*BUG*unknown*BUG*)";
297 cp =
"(*BUG*unknown*BUG*)";
301 cp =
"examine deferred";
311 LOG_ERROR(
"Invalid target event: %d", (
int)(event));
312 cp =
"(*BUG*unknown*BUG*)";
322 LOG_ERROR(
"Invalid target reset mode: %d", (
int)(reset_mode));
323 cp =
"(*BUG*unknown*BUG*)";
436 for (i = 0; i <
count; i++)
444 for (i = 0; i <
count; i++)
452 for (i = 0; i <
count; i++)
460 for (i = 0; i <
count; i++)
468 for (i = 0; i <
count; i++)
476 for (i = 0; i <
count; i++)
486 for (target = all_targets;
target; target = target->
next) {
497 if (parse_uint(
id, &num) !=
ERROR_OK)
500 for (target = all_targets;
target; target = target->
next) {
502 LOG_WARNING(
"use '%s' as target identifier, not '%u'",
519 target = target->
next;
529 if (target ==
NULL) {
530 LOG_ERROR(
"BUG: current_target out of bounds");
554 retval = target->
type->
poll(target);
565 LOG_INFO(
"Halt timed out, wake up GDB.");
583 retval = target->
type->
halt(target);
624 int handle_breakpoints,
int debug_execution)
640 retval = target->
type->
resume(target, current, address, handle_breakpoints, debug_execution);
661 for (target = all_targets;
target; target = target->
next)
672 sprintf(buf,
"ocd_process_reset %s", n->
name);
673 retval = Jim_Eval(cmd->
ctx->
interp, buf);
677 if (retval != JIM_OK) {
686 for (target = all_targets;
target; target = target->
next) {
758 for (target = all_targets;
target; target = target->
next) {
790 LOG_ERROR(
"Target %s does not support soft_reset_halt",
809 int num_mem_params,
struct mem_param *mem_params,
811 uint32_t entry_point, uint32_t exit_point,
821 LOG_ERROR(
"Target type '%s' does not support %s",
828 num_mem_params, mem_params,
829 num_reg_params, reg_param,
830 entry_point, exit_point, timeout_ms, arch_info);
844 int num_mem_params,
struct mem_param *mem_params,
845 int num_reg_params,
struct reg_param *reg_params,
846 uint32_t entry_point, uint32_t exit_point,
856 LOG_ERROR(
"Target type '%s' does not support %s",
861 LOG_ERROR(
"Target is already running an algorithm");
867 num_mem_params, mem_params,
868 num_reg_params, reg_params,
869 entry_point, exit_point, arch_info);
882 int num_mem_params,
struct mem_param *mem_params,
883 int num_reg_params,
struct reg_param *reg_params,
884 uint32_t exit_point,
int timeout_ms,
890 LOG_ERROR(
"Target type '%s' does not support %s",
895 LOG_ERROR(
"Target is not running an algorithm");
900 num_mem_params, mem_params,
901 num_reg_params, reg_params,
902 exit_point, timeout_ms, arch_info);
953 const uint8_t *
buffer, uint32_t
count,
int block_size,
954 int num_mem_params,
struct mem_param *mem_params,
955 int num_reg_params,
struct reg_param *reg_params,
956 uint32_t buffer_start, uint32_t buffer_size,
957 uint32_t entry_point, uint32_t exit_point,
void *
arch_info)
962 const uint8_t *buffer_orig =
buffer;
966 uint32_t wp_addr = buffer_start;
967 uint32_t rp_addr = buffer_start + 4;
968 uint32_t fifo_start_addr = buffer_start + 8;
969 uint32_t fifo_end_addr = buffer_start + buffer_size;
971 uint32_t wp = fifo_start_addr;
972 uint32_t rp = fifo_start_addr;
975 assert(!block_size || !(block_size & (block_size - 1)));
986 num_reg_params, reg_params,
992 LOG_ERROR(
"error starting target flash write algorithm");
1000 LOG_ERROR(
"failed to get read pointer");
1004 LOG_DEBUG(
"offs 0x%zx count 0x%" PRIx32
" wp 0x%" PRIx32
" rp 0x%" PRIx32,
1005 (
size_t) (buffer - buffer_orig), count, wp, rp);
1008 LOG_ERROR(
"flash write algorithm aborted by target");
1013 if (((rp - fifo_start_addr) & (block_size - 1)) || rp < fifo_start_addr || rp >= fifo_end_addr) {
1014 LOG_ERROR(
"corrupted fifo read pointer 0x%" PRIx32, rp);
1021 uint32_t thisrun_bytes;
1023 thisrun_bytes = rp - wp - block_size;
1024 else if (rp > fifo_start_addr)
1025 thisrun_bytes = fifo_end_addr - wp;
1027 thisrun_bytes = fifo_end_addr - wp - block_size;
1029 if (thisrun_bytes == 0) {
1038 if (timeout++ >= 2500) {
1039 LOG_ERROR(
"timeout waiting for algorithm, a target reset is recommended");
1049 if (thisrun_bytes > count * block_size)
1050 thisrun_bytes = count * block_size;
1053 if (thisrun_bytes >= 16)
1054 thisrun_bytes -= (rp + thisrun_bytes) & 0x03;
1062 buffer += thisrun_bytes;
1063 count -= thisrun_bytes / block_size;
1064 wp += thisrun_bytes;
1065 if (wp >= fifo_end_addr)
1066 wp = fifo_start_addr;
1083 num_reg_params, reg_params,
1089 LOG_ERROR(
"error waiting for target flash write algorithm");
1096 if (retval ==
ERROR_OK && rp == 0) {
1097 LOG_ERROR(
"flash write algorithm aborted by target");
1107 int num_mem_params,
struct mem_param *mem_params,
1108 int num_reg_params,
struct reg_param *reg_params,
1109 uint32_t buffer_start, uint32_t buffer_size,
1110 uint32_t entry_point, uint32_t exit_point,
void *
arch_info)
1115 const uint8_t *buffer_orig =
buffer;
1119 uint32_t wp_addr = buffer_start;
1120 uint32_t rp_addr = buffer_start + 4;
1121 uint32_t fifo_start_addr = buffer_start + 8;
1122 uint32_t fifo_end_addr = buffer_start + buffer_size;
1124 uint32_t wp = fifo_start_addr;
1125 uint32_t rp = fifo_start_addr;
1128 assert(!block_size || !(block_size & (block_size - 1)));
1139 num_reg_params, reg_params,
1145 LOG_ERROR(
"error starting target flash read algorithm");
1152 LOG_ERROR(
"failed to get write pointer");
1156 LOG_DEBUG(
"offs 0x%zx count 0x%" PRIx32
" wp 0x%" PRIx32
" rp 0x%" PRIx32,
1157 (
size_t)(buffer - buffer_orig), count, wp, rp);
1160 LOG_ERROR(
"flash read algorithm aborted by target");
1165 if (((wp - fifo_start_addr) & (block_size - 1)) || wp < fifo_start_addr || wp >= fifo_end_addr) {
1166 LOG_ERROR(
"corrupted fifo write pointer 0x%" PRIx32, wp);
1172 uint32_t thisrun_bytes;
1174 thisrun_bytes = wp - rp;
1176 thisrun_bytes = fifo_end_addr - rp;
1178 if (thisrun_bytes == 0) {
1187 if (timeout++ >= 2500) {
1188 LOG_ERROR(
"timeout waiting for algorithm, a target reset is recommended");
1198 if (thisrun_bytes > count * block_size)
1199 thisrun_bytes = count * block_size;
1202 if (thisrun_bytes >= 16)
1203 thisrun_bytes -= (rp + thisrun_bytes) & 0x03;
1211 buffer += thisrun_bytes;
1212 count -= thisrun_bytes / block_size;
1213 rp += thisrun_bytes;
1214 if (rp >= fifo_end_addr)
1215 rp = fifo_start_addr;
1233 num_reg_params, reg_params,
1239 LOG_ERROR(
"error waiting for target flash write algorithm");
1246 if (retval ==
ERROR_OK && wp == 0) {
1247 LOG_ERROR(
"flash read algorithm aborted by target");
1266 return target->
type->
read_memory(target, address, size, count, buffer);
1387 struct reg **reg_list[],
int *reg_list_size,
1398 reg_list_size, reg_class);
1409 struct reg **reg_list[],
int *reg_list_size,
1414 reg_list_size, reg_class) ==
ERROR_OK)
1435 retval = target->
type->
step(target, current, address, handle_breakpoints);
1479 uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
1481 return target->
type->
profiling(target, samples, max_num_samples,
1482 num_samples, seconds);
1561 for (target = all_targets;
target; target = target->
next) {
1589 static bool target_initialized;
1590 if (target_initialized) {
1591 LOG_INFO(
"'target init' has already been called");
1594 target_initialized =
true;
1621 while ((*callbacks_p)->next)
1622 callbacks_p = &((*callbacks_p)->next);
1623 callbacks_p = &((*callbacks_p)->next);
1627 (*callbacks_p)->callback =
callback;
1628 (*callbacks_p)->priv =
priv;
1629 (*callbacks_p)->next =
NULL;
1643 if (entry ==
NULL) {
1644 LOG_ERROR(
"error allocating buffer for reset callback entry");
1657 size_t len, uint8_t *data,
void *
priv),
void *priv)
1665 if (entry ==
NULL) {
1666 LOG_ERROR(
"error allocating buffer for trace callback entry");
1687 while ((*callbacks_p)->next)
1688 callbacks_p = &((*callbacks_p)->next);
1689 callbacks_p = &((*callbacks_p)->next);
1693 (*callbacks_p)->callback =
callback;
1694 (*callbacks_p)->type =
type;
1695 (*callbacks_p)->time_ms =
time_ms;
1696 (*callbacks_p)->removed =
false;
1701 (*callbacks_p)->priv =
priv;
1702 (*callbacks_p)->next =
NULL;
1750 size_t len, uint8_t *data,
void *
priv),
void *priv)
1775 if ((c->callback ==
callback) && (c->priv == priv)) {
1794 LOG_DEBUG(
"target event %i (%s) for core %s", event,
1801 next_callback = callback->
next;
1803 callback = next_callback;
1813 LOG_DEBUG(
"target reset %i (%s)", reset_mode,
1817 callback->
callback(target, reset_mode, callback->
priv);
1853 static bool callback_processing;
1856 if (callback_processing)
1859 callback_processing =
true;
1870 while (callback && *callback) {
1871 if ((*callback)->removed) {
1873 *callback = (*callback)->
next;
1878 bool call_it = (*callback)->callback &&
1885 callback = &(*callback)->
next;
1888 callback_processing =
false;
1920 assert(size <= area->size);
1923 if (size < area->size) {
1934 new_wa->
free =
true;
1936 area->
next = new_wa;
1951 while (c && c->
next) {
1982 retval = target->
type->
mmu(target, &enabled);
1988 LOG_DEBUG(
"MMU disabled, using physical " 1993 LOG_ERROR(
"No working memory available. " 1994 "Specify -work-area-phys to target.");
2004 LOG_ERROR(
"No working memory available. " 2005 "Specify -work-area-virt to target.");
2018 new_wa->
free =
true;
2026 size = (size + 3) & (~3UL);
2076 LOG_WARNING(
"not enough working area available(requested %"PRIu32
")", size);
2178 uint32_t max_size = 0;
2215 while (head !=
NULL) {
2242 target_event_callbacks =
NULL;
2250 target_timer_callbacks =
NULL;
2266 if (target ==
NULL) {
2289 int retcode,
int fileio_errno,
bool ctrl_c)
2295 uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
2302 LOG_INFO(
"Starting profiling. Halting and resuming the" 2303 " target as often as we can...");
2305 uint32_t sample_count = 0;
2314 samples[sample_count++] = t;
2323 LOG_INFO(
"Target not halted or running");
2332 if ((sample_count >= max_num_samples) ||
timeval_compare(&now, &timeout) >= 0) {
2333 LOG_INFO(
"Profiling completed. %" PRIu32
" samples.", sample_count);
2338 *num_samples = sample_count;
2359 if ((address + size - 1) < address) {
2361 LOG_ERROR(
"address + size wrapped (" TARGET_ADDR_FMT
", 0x%08" PRIx32
")",
2377 for (size = 1; size < 4 && count >= size * 2 + (address &
size); size *= 2) {
2378 if (address & size) {
2389 for (; size > 0; size /= 2) {
2390 uint32_t aligned = count - count %
size;
2421 if ((address + size - 1) < address) {
2423 LOG_ERROR(
"address + size wrapped (" TARGET_ADDR_FMT
", 0x%08" PRIx32
")",
2438 for (size = 1; size < 4 && count >= size * 2 + (address &
size); size *= 2) {
2439 if (address & size) {
2450 for (; size > 0; size /= 2) {
2451 uint32_t aligned = count - count %
size;
2470 uint32_t checksum = 0;
2478 buffer = malloc(size);
2479 if (buffer ==
NULL) {
2480 LOG_ERROR(
"error allocating buffer for section (%" PRIu32
" bytes)", size);
2490 for (i = 0; i < (size/
sizeof(uint32_t)); i++) {
2491 uint32_t target_data;
2507 uint8_t erased_value)
2522 uint8_t value_buf[8];
2546 uint8_t value_buf[4];
2570 uint8_t value_buf[2];
2617 uint8_t value_buf[8];
2638 uint8_t value_buf[4];
2659 uint8_t value_buf[2];
2698 uint8_t value_buf[8];
2719 uint8_t value_buf[4];
2740 uint8_t value_buf[2];
2779 if (target ==
NULL) {
2780 command_print(cmd,
"Target: %s is unknown, try one of:\n", name);
2785 "can't be the current target\n",
2811 command_print(
CMD,
"-- ------------------ ---------- ------ ------------------ ------------");
2819 state =
"tap-disabled";
2821 if (
CMD_CTX->current_target == target)
2826 "%2d%c %-18s %-10s %-6s %-18s %s",
2835 target = target->
next;
2853 static int prevSrstAsserted;
2854 static int prevPowerdropout;
2863 runPowerRestore = 1;
2866 static int64_t lastPower;
2867 bool waitMore = lastPower + 2000 > current;
2868 if (powerDropout && !waitMore) {
2869 runPowerDropout = 1;
2870 lastPower = current;
2880 static int64_t lastSrst;
2881 waitMore = lastSrst + 2000 > current;
2882 if (srstDeasserted && !waitMore) {
2883 runSrstDeasserted = 1;
2887 if (!prevSrstAsserted && srstAsserted)
2888 runSrstAsserted = 1;
2893 if (srstDeasserted || powerRestored) {
2906 Jim_Interp *interp = (Jim_Interp *)priv;
2915 static int recursive;
2923 int did_something = 0;
2924 if (runSrstAsserted) {
2925 LOG_INFO(
"srst asserted detected, running srst_asserted proc.");
2926 Jim_Eval(interp,
"srst_asserted");
2929 if (runSrstDeasserted) {
2930 Jim_Eval(interp,
"srst_deasserted");
2933 if (runPowerDropout) {
2934 LOG_INFO(
"Power dropout detected, running power_dropout proc.");
2935 Jim_Eval(interp,
"power_dropout");
2938 if (runPowerRestore) {
2939 Jim_Eval(interp,
"power_restore");
2943 if (did_something) {
2950 runSrstAsserted = 0;
2951 runSrstDeasserted = 0;
2952 runPowerRestore = 0;
2953 runPowerDropout = 0;
2979 if (!powerDropout && !srstAsserted) {
3002 LOG_USER(
"Examination failed, GDB will be halted. Polling again in %dms",
3039 i++, reg++, count++) {
3047 "(%i) %s (/%" PRIu32
"): 0x%s%s",
3060 cache = cache->
next;
3075 for (i = 0; i < cache->
num_regs; i++) {
3076 if (count++ == num) {
3083 cache = cache->
next;
3088 "has only %i registers (0 - %i)", num, count, count - 1);
3099 assert(reg !=
NULL);
3110 if (reg->
valid == 0)
3153 target->
tap->
enabled ?
"enabled" :
"disabled");
3179 int retval = parse_uint(
CMD_ARGV[0], &ms);
3197 int64_t then = 0, cur;
3204 if (target->
state == state)
3217 if ((cur-then) > ms) {
3218 LOG_ERROR(
"timed out while waiting for target %s",
3240 unsigned wait_local;
3241 retval = parse_uint(
CMD_ARGV[0], &wait_local);
3255 LOG_USER(
"requesting target halt and executing a soft reset");
3273 reset_mode = n->
value;
3327 const unsigned line_bytecnt = 32;
3328 unsigned line_modulo = line_bytecnt /
size;
3330 char output[line_bytecnt * 4 + 1];
3331 unsigned output_len = 0;
3333 const char *value_fmt;
3336 value_fmt =
"%16.16"PRIx64
" ";
3339 value_fmt =
"%8.8"PRIx64
" ";
3342 value_fmt =
"%4.4"PRIx64
" ";
3345 value_fmt =
"%2.2"PRIx64
" ";
3349 LOG_ERROR(
"invalid memory read size: %u", size);
3353 for (
unsigned i = 0; i <
count; i++) {
3354 if (i % line_modulo == 0) {
3355 output_len += snprintf(output + output_len,
3356 sizeof(output) - output_len,
3358 (address + (i * size)));
3362 const uint8_t *value_ptr = buffer + i *
size;
3376 output_len += snprintf(output + output_len,
3377 sizeof(output) - output_len,
3380 if ((i % line_modulo == line_modulo - 1) || (i == count - 1)) {
3410 bool physical = strcmp(
CMD_ARGV[0],
"phys") == 0;
3429 uint8_t *
buffer = calloc(count, size);
3430 if (buffer ==
NULL) {
3431 LOG_ERROR(
"Failed to allocate md read buffer");
3436 int retval = fn(target, address, size, count, buffer);
3459 const unsigned chunk_size = 16384;
3460 uint8_t *target_buf = malloc(chunk_size * data_size);
3461 if (target_buf ==
NULL) {
3466 for (
unsigned i = 0; i < chunk_size; i++) {
3467 switch (data_size) {
3487 for (
unsigned x = 0; x < c; x += chunk_size) {
3490 if (current > chunk_size)
3491 current = chunk_size;
3492 retval = fn(target, address + x * data_size, data_size, current, target_buf);
3508 bool physical = strcmp(
CMD_ARGV[0],
"phys") == 0;
3554 if (CMD_ARGC < 1 || CMD_ARGC > 5)
3574 *max_address += *min_address;
3577 if (*min_address > *max_address)
3587 uint32_t image_size;
3593 &image, &min_address, &max_address);
3607 for (
unsigned int i = 0; i < image.
num_sections; i++) {
3609 if (buffer == NULL) {
3611 "error allocating buffer for section (%d bytes)",
3624 uint32_t
length = buf_cnt;
3648 (
unsigned int)length,
3657 "in %fs (%0.3f KiB/s)", image_size,
3671 int retval, retvaltemp;
3682 uint32_t buf_size = (size > 4096) ? 4096 : size;
3683 buffer = malloc(buf_size);
3696 size_t size_written;
3697 uint32_t this_run_size = (size > buf_size) ? buf_size : size;
3702 retval =
fileio_write(fileio, this_run_size, buffer, &size_written);
3706 size -= this_run_size;
3707 address += this_run_size;
3718 "dumped %zu bytes in %fs (%0.3f KiB/s)", filesize,
3739 uint32_t image_size;
3741 uint32_t checksum = 0;
3742 uint32_t mem_checksum = 0;
3778 for (
unsigned int i = 0; i < image.
num_sections; i++) {
3780 if (buffer == NULL) {
3782 "error allocating buffer for section (%" PRIu32
" bytes)",
3811 if (checksum != mem_checksum) {
3816 LOG_ERROR(
"checksum mismatch - attempting binary compare");
3818 data = malloc(buf_cnt);
3823 for (t = 0; t < buf_cnt; t++) {
3824 if (data[t] != buffer[t]) {
3826 "diff %d address 0x%08x. Was 0x%02x instead of 0x%02x",
3831 if (diffs++ >= 127) {
3850 image_size += buf_cnt;
3859 "in %fs (%0.3f KiB/s)", image_size,
3887 while (breakpoint) {
3894 breakpoint->
set, buf);
3897 if ((breakpoint->
address == 0) && (breakpoint->
asid != 0))
3898 command_print(cmd,
"Context breakpoint: 0x%8.8" PRIx32
", 0x%x, %i",
3901 else if ((breakpoint->
address != 0) && (breakpoint->
asid != 0)) {
3905 command_print(cmd,
"\t|--->linked with ContextID: 0x%8.8" PRIx32,
3913 breakpoint = breakpoint->
next;
3930 }
else if (addr == 0) {
3932 LOG_ERROR(
"Context breakpoint not available");
3938 command_print(cmd,
"Context breakpoint set at 0x%8.8" PRIx32
"", asid);
3942 LOG_ERROR(
"Hybrid breakpoint not available");
3948 command_print(cmd,
"Hybrid breakpoint set at 0x%8.8" PRIx32
"", asid);
3971 if (strcmp(
CMD_ARGV[2],
"hw") == 0) {
3977 }
else if (strcmp(
CMD_ARGV[2],
"hw_ctx") == 0) {
4023 while (watchpoint) {
4025 ", len: 0x%8.8" PRIx32
4026 ", r/w/a: %i, value: 0x%8.8" PRIx32
4027 ", mask: 0x%8.8" PRIx32,
4030 (
int)watchpoint->
rw,
4033 watchpoint = watchpoint->
next;
4041 uint32_t data_value = 0x0;
4042 uint32_t data_mask = 0xffffffff;
4077 data_value, data_mask);
4079 LOG_ERROR(
"Failure setting watchpoints");
4121 static void writeData(FILE *f,
const void *data,
size_t len)
4123 size_t written = fwrite(data, 1, len, f);
4125 LOG_ERROR(
"failed to write %zu bytes: %s", len, strerror(errno));
4128 static void writeLong(FILE *f,
int l,
struct target *target)
4144 static void write_gmon(uint32_t *samples, uint32_t sampleNum,
const char *filename,
bool with_range,
4145 uint32_t start_address, uint32_t end_address,
struct target *target, uint32_t duration_ms)
4148 FILE *f = fopen(filename,
"w");
4164 min = start_address;
4169 for (i = 0; i < sampleNum; i++) {
4170 if (min > samples[i])
4172 if (max < samples[i])
4181 int addressSpace = max - min;
4182 assert(addressSpace >= 2);
4186 static const uint32_t maxBuckets = 128 * 1024;
4187 uint32_t numBuckets = addressSpace /
sizeof(
UNIT);
4188 if (numBuckets > maxBuckets)
4189 numBuckets = maxBuckets;
4190 int *buckets = malloc(
sizeof(
int) * numBuckets);
4191 if (buckets ==
NULL) {
4195 memset(buckets, 0,
sizeof(
int) * numBuckets);
4196 for (i = 0; i < sampleNum; i++) {
4197 uint32_t address = samples[i];
4199 if ((address < min) || (max <= address))
4202 long long a = address - min;
4203 long long b = numBuckets;
4204 long long c = addressSpace;
4205 int index_t = (a * b) / c;
4213 float sample_rate = sampleNum / (duration_ms / 1000.0);
4216 for (i = 0; i < (15-strlen(
"seconds")); i++)
4222 char *data = malloc(2 * numBuckets);
4224 for (i = 0; i < numBuckets; i++) {
4229 data[i * 2] = val&0xff;
4230 data[i * 2 + 1] = (val >> 8) & 0xff;
4250 const uint32_t MAX_PROFILE_SAMPLE_NUM = 10000;
4252 uint32_t num_of_samples;
4258 uint32_t *samples = malloc(
sizeof(uint32_t) * MAX_PROFILE_SAMPLE_NUM);
4259 if (samples ==
NULL) {
4260 LOG_ERROR(
"No memory to store samples.");
4271 &num_of_samples, offset);
4276 uint32_t duration_ms =
timeval_ms() - timestart_ms;
4278 assert(num_of_samples <= MAX_PROFILE_SAMPLE_NUM);
4310 uint32_t start_address = 0;
4311 uint32_t end_address = 0;
4312 bool with_range =
false;
4320 with_range, start_address, end_address, target, duration_ms);
4330 Jim_Obj *nameObjPtr, *valObjPtr;
4337 nameObjPtr = Jim_NewStringObj(interp, namebuf, -1);
4338 valObjPtr = Jim_NewIntObj(interp, val);
4339 if (!nameObjPtr || !valObjPtr) {
4344 Jim_IncrRefCount(nameObjPtr);
4345 Jim_IncrRefCount(valObjPtr);
4346 result = Jim_SetVariable(interp, nameObjPtr, valObjPtr);
4347 Jim_DecrRefCount(interp, nameObjPtr);
4348 Jim_DecrRefCount(interp, valObjPtr);
4360 assert(context !=
NULL);
4363 if (target ==
NULL) {
4364 LOG_ERROR(
"mem2array: no current target");
4371 static int target_mem2array(Jim_Interp *interp,
struct target *target,
int argc, Jim_Obj *
const *argv)
4379 const char *varname;
4391 if (argc < 4 || argc > 5) {
4392 Jim_WrongNumArgs(interp, 0, argv,
"varname width addr nelems [phys]");
4395 varname = Jim_GetString(argv[0], &len);
4398 e = Jim_GetLong(interp, argv[1], &l);
4403 e = Jim_GetLong(interp, argv[2], &l);
4407 e = Jim_GetLong(interp, argv[3], &l);
4413 phys = Jim_GetString(argv[4], &n);
4414 if (!strncmp(phys,
"phys", n))
4430 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4431 Jim_AppendStrings(interp, Jim_GetResult(interp),
"Invalid width param, must be 8/16/32",
NULL);
4435 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4436 Jim_AppendStrings(interp, Jim_GetResult(interp),
"mem2array: zero width read?",
NULL);
4439 if ((addr + (len * width)) < addr) {
4440 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4441 Jim_AppendStrings(interp, Jim_GetResult(interp),
"mem2array: addr + len - wraps to zero?",
NULL);
4446 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4447 Jim_AppendStrings(interp, Jim_GetResult(interp),
"mem2array: absurd > 64K item request",
NULL);
4452 ((width == 2) && ((addr & 1) == 0)) ||
4453 ((width == 4) && ((addr & 3) == 0))) {
4457 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4458 sprintf(buf,
"mem2array address: 0x%08" PRIx32
" is not aligned for %" PRIu32
" byte reads",
4461 Jim_AppendStrings(interp, Jim_GetResult(interp), buf,
NULL);
4470 size_t buffersize = 4096;
4471 uint8_t *
buffer = malloc(buffersize);
4481 if (count > (buffersize / width))
4482 count = (buffersize /
width);
4490 LOG_ERROR(
"mem2array: Read @ 0x%08" PRIx32
", w=%" PRIu32
", cnt=%" PRIu32
", failed",
4494 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4495 Jim_AppendStrings(interp, Jim_GetResult(interp),
"mem2array: cannot read memory",
NULL);
4500 for (i = 0; i <
count ; i++, n++) {
4509 v = buffer[i] & 0x0ff;
4515 addr += count *
width;
4521 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4529 Jim_Obj *nameObjPtr, *valObjPtr;
4537 nameObjPtr = Jim_NewStringObj(interp, namebuf, -1);
4543 Jim_IncrRefCount(nameObjPtr);
4544 valObjPtr = Jim_GetVariable(interp, nameObjPtr, JIM_ERRMSG);
4545 Jim_DecrRefCount(interp, nameObjPtr);
4547 if (valObjPtr ==
NULL)
4550 result = Jim_GetLong(interp, valObjPtr, &l);
4562 assert(context !=
NULL);
4565 if (target ==
NULL) {
4566 LOG_ERROR(
"array2mem: no current target");
4574 int argc, Jim_Obj *
const *argv)
4582 const char *varname;
4593 if (argc < 4 || argc > 5) {
4594 Jim_WrongNumArgs(interp, 0, argv,
"varname width addr nelems [phys]");
4597 varname = Jim_GetString(argv[0], &len);
4600 e = Jim_GetLong(interp, argv[1], &l);
4605 e = Jim_GetLong(interp, argv[2], &l);
4609 e = Jim_GetLong(interp, argv[3], &l);
4615 phys = Jim_GetString(argv[4], &n);
4616 if (!strncmp(phys,
"phys", n))
4632 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4633 Jim_AppendStrings(interp, Jim_GetResult(interp),
4634 "Invalid width param, must be 8/16/32",
NULL);
4638 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4639 Jim_AppendStrings(interp, Jim_GetResult(interp),
4640 "array2mem: zero width read?",
NULL);
4643 if ((addr + (len * width)) < addr) {
4644 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4645 Jim_AppendStrings(interp, Jim_GetResult(interp),
4646 "array2mem: addr + len - wraps to zero?",
NULL);
4651 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4652 Jim_AppendStrings(interp, Jim_GetResult(interp),
4653 "array2mem: absurd > 64K item request",
NULL);
4658 ((width == 2) && ((addr & 1) == 0)) ||
4659 ((width == 4) && ((addr & 3) == 0))) {
4663 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4664 sprintf(buf,
"array2mem address: 0x%08" PRIx32
" is not aligned for %" PRIu32
" byte reads",
4667 Jim_AppendStrings(interp, Jim_GetResult(interp), buf,
NULL);
4678 size_t buffersize = 4096;
4679 uint8_t *
buffer = malloc(buffersize);
4687 if (count > (buffersize / width))
4688 count = (buffersize /
width);
4691 for (i = 0; i <
count; i++, n++) {
4701 buffer[i] = v & 0x0ff;
4713 LOG_ERROR(
"array2mem: Write @ 0x%08" PRIx32
", w=%" PRIu32
", cnt=%" PRIu32
", failed",
4717 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4718 Jim_AppendStrings(interp, Jim_GetResult(interp),
"array2mem: cannot read memory",
NULL);
4722 addr += count *
width;
4727 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4741 if (teap->
event == e) {
4742 LOG_DEBUG(
"target(%d): %s (%s) event: %d (%s) action: %s",
4758 retval = Jim_EvalObj(teap->
interp, teap->
body);
4765 if (retval == JIM_RETURN)
4766 retval = teap->
interp->returnCode;
4768 if (retval != JIM_OK) {
4769 Jim_MakeErrorMessage(teap->
interp);
4770 LOG_USER(
"Error executing event %s on target %s:\n%s",
4773 Jim_GetString(Jim_GetResult(teap->
interp),
NULL));
4775 Jim_Eval(teap->
interp,
"error \"\" \"\"");
4789 if (teap->
event == event)
4823 { .name =
"-rtos", .value =
TCFG_RTOS },
4827 { .name =
NULL, .value = -1 }
4838 while (goi->
argc > 0) {
4839 Jim_SetEmptyResult(goi->
interp);
4865 Jim_SetResultFormatted(goi->
interp,
4866 "not settable: %s", n->
name);
4870 if (goi->
argc != 0) {
4871 Jim_WrongNumArgs(goi->
interp,
4877 Jim_SetResultString(goi->
interp,
4882 if (goi->
argc == 0) {
4883 Jim_WrongNumArgs(goi->
interp, goi->
argc, goi->
argv,
"-event ?event-name? ...");
4894 if (goi->
argc != 1) {
4895 Jim_WrongNumArgs(goi->
interp, goi->
argc, goi->
argv,
"-event ?event-name? ?EVENT-BODY?");
4899 if (goi->
argc != 0) {
4900 Jim_WrongNumArgs(goi->
interp, goi->
argc, goi->
argv,
"-event ?event-name?");
4917 bool replace =
true;
4920 teap = calloc(1,
sizeof(*teap));
4928 teap->
body = Jim_DuplicateObj(goi->
interp, o);
4939 Jim_IncrRefCount(teap->
body);
4946 Jim_SetEmptyResult(goi->
interp);
4950 Jim_SetEmptyResult(goi->
interp);
5039 Jim_SetResultString(goi->
interp, n->
name, -1);
5048 target->
coreid = (int32_t)w;
5063 Jim_SetResultString(goi->
interp,
5064 "target requires -dap parameter instead of -chain-position!", -1);
5089 target->
dbgbase = (uint32_t)w;
5102 if (result != JIM_OK)
5118 Jim_SetResultString(goi->
interp,
"-gdb-port must be configured before 'init'", -1);
5139 Jim_SetResultString(goi->
interp,
"-gdb-max-conenctions must be configured before 'init'", -1);
5169 "missing: -option ...");
5172 struct target *target = Jim_CmdPrivData(goi.
interp);
5177 int argc, Jim_Obj *
const *argv)
5179 struct target *target = Jim_CmdPrivData(interp);
5184 int argc, Jim_Obj *
const *argv)
5186 struct target *target = Jim_CmdPrivData(interp);
5192 Jim_SetResultFormatted(interp,
"[TAP is disabled]");
5198 bool allow_defer =
false;
5204 Jim_SetResultFormatted(goi.
interp,
5205 "usage: %s ['allow-defer']", cmd_name);
5209 strcmp(Jim_GetString(argv[1],
NULL),
"allow-defer") == 0) {
5218 struct target *target = Jim_CmdPrivData(interp);
5224 LOG_INFO(
"Use arp_examine command to examine it manually!");
5236 struct target *target = Jim_CmdPrivData(interp);
5244 struct target *target = Jim_CmdPrivData(interp);
5253 Jim_WrongNumArgs(interp, 1, argv,
"[no parameters]");
5256 struct target *target = Jim_CmdPrivData(interp);
5267 Jim_WrongNumArgs(interp, 1, argv,
"[no parameters]");
5270 struct target *target = Jim_CmdPrivData(interp);
5289 if (goi.
argc != 2) {
5290 Jim_WrongNumArgs(interp, 0, argv,
5291 "([tT]|[fF]|assert|deassert) BOOL");
5307 struct target *target = Jim_CmdPrivData(goi.
interp);
5312 Jim_SetResultFormatted(interp,
5313 "No target-specific reset for %s",
5331 return (e ==
ERROR_OK) ? JIM_OK : JIM_ERR;
5337 Jim_WrongNumArgs(interp, 1, argv,
"[no parameters]");
5340 struct target *target = Jim_CmdPrivData(interp);
5343 int e = target->
type->
halt(target);
5344 return (e ==
ERROR_OK) ? JIM_OK : JIM_ERR;
5353 if (goi.
argc != 2) {
5355 Jim_SetResultFormatted(goi.
interp,
5356 "%s <state_name> <timeout_in_msec>", cmd_name);
5370 struct target *target = Jim_CmdPrivData(interp);
5376 Jim_Obj *eObj = Jim_NewIntObj(interp, e);
5377 Jim_SetResultFormatted(goi.
interp,
5378 "target: %s wait %s fails (%#s) %s",
5398 "----------------------------------------");
5411 Jim_WrongNumArgs(interp, 1, argv,
"[no parameters]");
5414 struct target *target = Jim_CmdPrivData(interp);
5422 if (goi.
argc != 1) {
5424 Jim_SetResultFormatted(goi.
interp,
"%s <eventname>", cmd_name);
5433 struct target *target = Jim_CmdPrivData(interp);
5440 .
name =
"configure",
5443 .help =
"configure a new target for use",
5444 .usage =
"[target_attribute ...]",
5450 .help =
"returns the specified target attribute",
5451 .usage =
"target_attribute",
5455 .handler = handle_mw_command,
5457 .help =
"Write 64-bit word(s) to target memory",
5458 .usage =
"address data [count]",
5462 .handler = handle_mw_command,
5464 .help =
"Write 32-bit word(s) to target memory",
5465 .usage =
"address data [count]",
5469 .handler = handle_mw_command,
5471 .help =
"Write 16-bit half-word(s) to target memory",
5472 .usage =
"address data [count]",
5476 .handler = handle_mw_command,
5478 .help =
"Write byte(s) to target memory",
5479 .usage =
"address data [count]",
5483 .handler = handle_md_command,
5485 .help =
"Display target memory as 64-bit words",
5486 .usage =
"address [count]",
5490 .handler = handle_md_command,
5492 .help =
"Display target memory as 32-bit words",
5493 .usage =
"address [count]",
5497 .handler = handle_md_command,
5499 .help =
"Display target memory as 16-bit half-words",
5500 .usage =
"address [count]",
5504 .handler = handle_md_command,
5506 .help =
"Display target memory as 8-bit bytes",
5507 .usage =
"address [count]",
5510 .name =
"array2mem",
5513 .help =
"Writes Tcl array of 8/16/32 bit numbers " 5515 .usage =
"arrayname bitwidth address count",
5518 .name =
"mem2array",
5521 .help =
"Loads Tcl array of 8/16/32 bit numbers " 5522 "from target memory",
5523 .usage =
"arrayname bitwidth address count",
5526 .name =
"eventlist",
5527 .handler = handle_target_event_list,
5529 .help =
"displays a table of events defined for this target",
5536 .help =
"displays the current state of this target",
5539 .name =
"arp_examine",
5542 .help =
"used internally for reset processing",
5543 .usage =
"['allow-defer']",
5546 .name =
"was_examined",
5549 .help =
"used internally for reset processing",
5552 .name =
"examine_deferred",
5555 .help =
"used internally for reset processing",
5558 .name =
"arp_halt_gdb",
5561 .help =
"used internally for reset processing to halt GDB",
5567 .help =
"used internally for reset processing",
5570 .name =
"arp_reset",
5573 .help =
"used internally for reset processing",
5579 .help =
"used internally for reset processing",
5582 .name =
"arp_waitstate",
5585 .help =
"used internally for reset processing",
5588 .name =
"invoke-event",
5591 .help =
"invoke handler for specified event",
5592 .usage =
"event_name",
5608 assert(cmd_ctx !=
NULL);
5610 if (goi->
argc < 3) {
5611 Jim_WrongNumArgs(goi->
interp, 1, goi->
argv,
"?name? ?type? ..options...");
5618 cmd = Jim_GetCommand(goi->
interp, new_cmd, JIM_ERRMSG);
5620 cp = Jim_GetString(new_cmd,
NULL);
5621 Jim_SetResultFormatted(goi->
interp,
"Command/target: %s Exists", cp);
5633 LOG_ERROR(
"The selected transport doesn't support this target");
5636 LOG_INFO(
"The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD");
5639 for (x = 0 ; target_types[x] ; x++) {
5640 if (0 == strcmp(cp, target_types[x]->
name)) {
5646 if (target_types[x]->deprecated_name) {
5647 if (0 == strcmp(cp, target_types[x]->deprecated_name)) {
5649 LOG_WARNING(
"target name is deprecated use: \'%s\'", target_types[x]->
name);
5654 if (target_types[x] ==
NULL) {
5655 Jim_SetResultFormatted(goi->
interp,
"Unknown target type %s, try one of ", cp);
5656 for (x = 0 ; target_types[x] ; x++) {
5657 if (target_types[x + 1]) {
5658 Jim_AppendStrings(goi->
interp,
5659 Jim_GetResult(goi->
interp),
5660 target_types[x]->
name,
5663 Jim_AppendStrings(goi->
interp,
5664 Jim_GetResult(goi->
interp),
5673 target = calloc(1,
sizeof(
struct target));
5684 if (!target->
type) {
5742 Jim_SetResultString(goi->
interp,
"-dap ?name? required when creating target", -1);
5747 Jim_SetResultString(goi->
interp,
"-chain-position ?name? required when creating target", -1);
5770 cp = Jim_GetString(new_cmd,
NULL);
5800 LOG_ERROR(
"unable to register '%s' commands", cp);
5817 .help =
"target command group",
5819 .chain = target_subcommands,
5850 Jim_WrongNumArgs(interp, 1, argv,
"Too many parameters");
5854 assert(cmd_ctx !=
NULL);
5858 Jim_SetResultString(interp,
target_name(target), -1);
5865 Jim_WrongNumArgs(interp, 1, argv,
"Too many parameters");
5868 Jim_SetResult(interp, Jim_NewListObj(interp,
NULL, 0));
5869 for (
unsigned x = 0;
NULL != target_types[x]; x++) {
5870 Jim_ListAppendElement(interp, Jim_GetResult(interp),
5871 Jim_NewStringObj(interp, target_types[x]->
name, -1));
5879 Jim_WrongNumArgs(interp, 1, argv,
"Too many parameters");
5882 Jim_SetResult(interp, Jim_NewListObj(interp,
NULL, 0));
5885 Jim_ListAppendElement(interp, Jim_GetResult(interp),
5886 Jim_NewStringObj(interp,
target_name(target), -1));
5887 target = target->
next;
5895 const char *targetname;
5897 struct target *target = (
struct target *)
NULL;
5909 for (i = 1; i < argc; i++) {
5911 targetname = Jim_GetString(argv[i], &len);
5933 target->
head = head;
5937 if (target && target->
rtos)
5950 "<name> <target_type> [<target_options> ...]");
5960 .handler = handle_target_init_command,
5961 .help =
"initialize targets",
5968 .usage =
"name type '-chain-position' name [options ...]",
5969 .help =
"Creates and selects a new target",
5975 .help =
"Returns the currently selected target",
5981 .help =
"Returns the available target types as " 5982 "a list of strings",
5988 .help =
"Returns the names of all targets as a list of strings",
5994 .usage =
"targetname1 targetname2 ...",
5995 .help =
"gather several target in a smp list" 6013 if (fastload !=
NULL) {
6015 free(fastload[i].
data);
6025 uint32_t image_size;
6032 &image, &min_address, &max_address);
6047 if (fastload == NULL) {
6053 for (
unsigned int i = 0; i < image.
num_sections; i++) {
6055 if (buffer == NULL) {
6069 uint32_t
length = buf_cnt;
6085 fastload[i].
data = malloc(length);
6086 if (fastload[i].
data == NULL) {
6088 command_print(
CMD,
"error allocating buffer for section (%" PRIu32
" bytes)",
6093 memcpy(fastload[i].
data, buffer + offset, length);
6098 (
unsigned int)length,
6107 "in %fs (%0.3f KiB/s)", image_size,
6111 "WARNING: image has not been loaded to target!" 6112 "You can issue a 'fast_load' to finish loading.");
6127 if (fastload ==
NULL) {
6138 (
unsigned int)(fastload[i].address),
6139 (
unsigned int)(fastload[i].
length));
6143 size += fastload[i].
length;
6147 command_print(
CMD,
"Loaded image %f kBytes/s", (
float)(size/1024.0)/((
float)(after-ms)/1000.0));
6155 .handler = handle_targets_command,
6157 .help =
"change current default target (one parameter) " 6158 "or prints table of all targets (no parameters)",
6159 .usage =
"[target]",
6164 .help =
"configure target",
6186 &target_reset_nag,
"Nag after each reset about options to improve " 6215 for (
int i = 0; i <
size; i++)
6237 size_t num_bytes = test_size + 4;
6246 uint8_t *test_pattern = malloc(num_bytes);
6248 for (
size_t i = 0; i < num_bytes; i++)
6249 test_pattern[i] = rand();
6257 for (
int host_offset = 0; host_offset <= 1; host_offset++) {
6258 for (
int size = 1; size <= 4; size *= 2) {
6260 uint32_t count = test_size /
size;
6261 size_t host_bufsiz = (count + 2) * size + host_offset;
6262 uint8_t *read_ref = malloc(host_bufsiz);
6263 uint8_t *read_buf = malloc(host_bufsiz);
6265 for (
size_t i = 0; i < host_bufsiz; i++) {
6266 read_ref[i] = rand();
6267 read_buf[i] = read_ref[i];
6270 "Test read %" PRIu32
" x %d @ %d to %saligned buffer: ", count,
6271 size,
offset, host_offset ?
"un" :
"");
6277 read_buf + size + host_offset);
6290 memcpy(read_ref + size + host_offset, test_pattern +
offset, count * size);
6293 int result = memcmp(read_ref, read_buf, host_bufsiz);
6317 num_bytes = test_size + 4 + 4 + 4;
6325 test_pattern = malloc(num_bytes);
6327 for (
size_t i = 0; i < num_bytes; i++)
6328 test_pattern[i] = rand();
6330 for (
int host_offset = 0; host_offset <= 1; host_offset++) {
6331 for (
int size = 1; size <= 4; size *= 2) {
6333 uint32_t count = test_size /
size;
6334 size_t host_bufsiz = count * size + host_offset;
6335 uint8_t *read_ref = malloc(num_bytes);
6336 uint8_t *read_buf = malloc(num_bytes);
6337 uint8_t *write_buf = malloc(host_bufsiz);
6339 for (
size_t i = 0; i < host_bufsiz; i++)
6340 write_buf[i] = rand();
6342 "Test write %" PRIu32
" x %d @ %d from %saligned buffer: ", count,
6343 size,
offset, host_offset ?
"un" :
"");
6352 memcpy(read_ref, test_pattern, num_bytes);
6353 memcpy(read_ref + size +
offset, write_buf + host_offset, count * size);
6359 write_buf + host_offset);
6379 int result = memcmp(read_ref, read_buf, num_bytes);
6405 .
name =
"fast_load_image",
6406 .handler = handle_fast_load_image_command,
6408 .help =
"Load image into server memory for later use by " 6409 "fast_load; primarily for profiling",
6410 .usage =
"filename address ['bin'|'ihex'|'elf'|'s19'] " 6411 "[min_address [max_length]]",
6414 .name =
"fast_load",
6415 .handler = handle_fast_load_command,
6417 .help =
"loads active fast load image to current target " 6418 "- mainly for profiling purposes",
6423 .handler = handle_profile_command,
6425 .usage =
"seconds filename [start end]",
6426 .help =
"profiling samples the CPU PC",
6430 .name =
"virt2phys",
6431 .handler = handle_virt2phys_command,
6433 .help =
"translate a virtual address into a physical address",
6434 .usage =
"virtual_address",
6438 .handler = handle_reg_command,
6440 .help =
"display (reread from target with \"force\") or set a register; " 6441 "with no arguments, displays all registers and their values",
6442 .usage =
"[(register_number|register_name) [(value|'force')]]",
6446 .handler = handle_poll_command,
6448 .help =
"poll target state; or reconfigure background polling",
6449 .usage =
"['on'|'off']",
6452 .name =
"wait_halt",
6453 .handler = handle_wait_halt_command,
6455 .help =
"wait up to the specified number of milliseconds " 6456 "(default 5000) for a previously requested halt",
6457 .usage =
"[milliseconds]",
6461 .handler = handle_halt_command,
6463 .help =
"request target to halt, then wait up to the specified " 6464 "number of milliseconds (default 5000) for it to complete",
6465 .usage =
"[milliseconds]",
6469 .handler = handle_resume_command,
6471 .help =
"resume target execution from current PC or address",
6472 .usage =
"[address]",
6476 .handler = handle_reset_command,
6478 .usage =
"[run|halt|init]",
6479 .help =
"Reset all targets into the specified mode. " 6480 "Default reset mode is run, if not given.",
6483 .name =
"soft_reset_halt",
6484 .handler = handle_soft_reset_halt_command,
6487 .help =
"halt the target and do a soft reset",
6491 .handler = handle_step_command,
6493 .help =
"step one instruction from current PC or address",
6494 .usage =
"[address]",
6498 .handler = handle_md_command,
6500 .help =
"display memory double-words",
6501 .usage =
"['phys'] address [count]",
6505 .handler = handle_md_command,
6507 .help =
"display memory words",
6508 .usage =
"['phys'] address [count]",
6512 .handler = handle_md_command,
6514 .help =
"display memory half-words",
6515 .usage =
"['phys'] address [count]",
6519 .handler = handle_md_command,
6521 .help =
"display memory bytes",
6522 .usage =
"['phys'] address [count]",
6526 .handler = handle_mw_command,
6528 .help =
"write memory double-word",
6529 .usage =
"['phys'] address value [count]",
6533 .handler = handle_mw_command,
6535 .help =
"write memory word",
6536 .usage =
"['phys'] address value [count]",
6540 .handler = handle_mw_command,
6542 .help =
"write memory half-word",
6543 .usage =
"['phys'] address value [count]",
6547 .handler = handle_mw_command,
6549 .help =
"write memory byte",
6550 .usage =
"['phys'] address value [count]",
6554 .handler = handle_bp_command,
6556 .help =
"list or set hardware or software breakpoint",
6557 .usage =
"[<address> [<asid>] <length> ['hw'|'hw_ctx']]",
6561 .handler = handle_rbp_command,
6563 .help =
"remove breakpoint",
6564 .usage =
"'all' | address",
6568 .handler = handle_wp_command,
6570 .help =
"list (no params) or create watchpoints",
6571 .usage =
"[address length [('r'|'w'|'a') value [mask]]]",
6575 .handler = handle_rwp_command,
6577 .help =
"remove watchpoint",
6581 .name =
"load_image",
6582 .handler = handle_load_image_command,
6584 .usage =
"filename address ['bin'|'ihex'|'elf'|'s19'] " 6585 "[min_address] [max_length]",
6588 .name =
"dump_image",
6589 .handler = handle_dump_image_command,
6591 .usage =
"filename address size",
6594 .name =
"verify_image_checksum",
6595 .handler = handle_verify_image_checksum_command,
6597 .usage =
"filename [offset [type]]",
6600 .name =
"verify_image",
6601 .handler = handle_verify_image_command,
6603 .usage =
"filename [offset [type]]",
6606 .name =
"test_image",
6607 .handler = handle_test_image_command,
6609 .usage =
"filename [offset [type]]",
6612 .name =
"mem2array",
6615 .help =
"read 8/16/32 bit memory and return as a TCL array " 6616 "for script processing",
6617 .usage =
"arrayname bitwidth address count",
6620 .name =
"array2mem",
6623 .help =
"convert a TCL array to memory locations " 6624 "and write the 8/16/32 bit values",
6625 .usage =
"arrayname bitwidth address count",
6628 .name =
"reset_nag",
6629 .handler = handle_target_reset_nag,
6631 .help =
"Nag after each reset about options that could have been " 6632 "enabled to improve performance. ",
6633 .usage =
"['enable'|'disable']",
6637 .handler = handle_ps_command,
6639 .help =
"list all tasks ",
6643 .name =
"test_mem_access",
6644 .handler = handle_test_mem_access_command,
6646 .help =
"Test the target's memory access functions",
static int target_call_timer_callbacks_check_time(int checktime)
struct target_type arm9tdmi_target
Holds methods for ARM9TDMI targets.
static void writeString(FILE *f, char *s)
int target_write_phys_u32(struct target *target, target_addr_t address, uint32_t value)
static int jim_target_current(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
bool defer_examine
Should we defer examine to later.
static int jim_target_current_state(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int handle_bp_command_set(struct command_invocation *cmd, target_addr_t addr, uint32_t asid, uint32_t length, int hw)
target_addr_t target_address_max(struct target *target)
Return the highest accessible address for this target.
static void writeLong(FILE *f, int l, struct target *target)
const char * target_reset_mode_name(enum target_reset_mode reset_mode)
Return the name of a target reset reason enumeration value.
#define ERROR_FLASH_OPERATION_FAILED
int(* target_jim_configure)(struct target *target, Jim_GetOptInfo *goi)
static void append_to_list_all_targets(struct target *target)
struct target_type quark_x10xx_target
void target_free_all_working_areas(struct target *target)
int(* profiling)(struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
static int target_array2mem(Jim_Interp *interp, struct target *target, int argc, Jim_Obj *const *argv)
void command_set_handler_data(struct command *c, void *p)
Update the private command data field for a command and all descendents.
static void target_set_examined(struct target *target)
Sets the examined flag for the given target.
static void print_wa_layout(struct target *target)
int fileio_size(struct fileio *fileio, size_t *size)
FIX!!!!
int target_call_timer_callbacks(void)
const char * target_state_name(struct target *t)
Return the name of this targets current state.
static struct target_type * target_types[]
int(* override_target)(const char **targetname)
Optional.
target_addr_t working_area
static const Jim_Nvp nvp_target_event[]
const struct reg_arch_type * type
static int target_call_timer_callback(struct target_timer_callback *cb, struct timeval *now)
void target_buffer_set_u16(struct target *target, uint8_t *buffer, uint16_t value)
static int new_target_number(void)
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
int jtag_srst_asserted(int *srst_asserted)
int jtag_power_dropout(int *dropout)
int(* write_memory)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Target memory write callback.
void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, const uint16_t *srcbuf)
#define LOG_USER(expr ...)
struct target_list * head
static void list_add(struct list_head *new, struct list_head *head)
list_add - add a new entry : new entry to be added : list head to add it after
static int target_restore_working_area(struct target *target, struct working_area *area)
target_addr_t working_area_phys
static void target_free_all_working_areas_restore(struct target *target, int restore)
int target_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
Obtain the registers for GDB.
static int jim_target_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
int(* remove_watchpoint)(struct target *target, struct watchpoint *watchpoint)
struct reg * register_get_by_name(struct reg_cache *first, const char *name, bool search_all)
#define CMD_NAME
Use this macro to access the name of the command being handled, rather than accessing the variable di...
static int jim_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int target_read_phys_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
struct target_type avr_target
int target_write_phys_u64(struct target *target, target_addr_t address, uint64_t value)
static int jim_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int register_commands(struct command_context *cmd_ctx, struct command *parent, const struct command_registration *cmds)
Register one or more commands in the specified context, as children of parent (or top-level commends...
struct target_type ls1_sap_target
int target_checksum_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t *crc)
void target_handle_event(struct target *target, enum target_event e)
int duration_measure(struct duration *duration)
Update the duration->elapsed field to finish the duration measurment.
const char * name
Name of this type of target.
static void h_u32_to_le(uint8_t *buf, int val)
static const Jim_Nvp nvp_error_target[]
void jtag_poll_set_enabled(bool value)
Assign flag reporting whether JTAG polling is disallowed.
int(* arch_state)(struct target *target)
struct working_area * working_areas
struct target_type dragonite_target
int(* init_target)(struct command_context *cmd_ctx, struct target *target)
static int runSrstDeasserted
int target_wait_state(struct target *target, enum target_state state, int ms)
int target_read_u64(struct target *target, target_addr_t address, uint64_t *value)
char * buf_to_hex_str(const void *_buf, unsigned buf_len)
bool running_alg
true if the target is currently running a downloaded "algorithm" instead of arbitrary user code...
When run_command is called, a new instance will be created on the stack, filled with the proper value...
static void h_u16_to_be(uint8_t *buf, int val)
int(* add_watchpoint)(struct target *target, struct watchpoint *watchpoint)
int target_read_u16(struct target *target, target_addr_t address, uint16_t *value)
struct target * get_target(const char *id)
static int target_fill_mem(struct target *target, target_addr_t address, target_write_fn fn, unsigned data_size, uint64_t b, unsigned c)
static int jim_target_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
A TCL -ish GetOpt like code.
static int jim_target_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
void target_buffer_get_u64_array(struct target *target, const uint8_t *buffer, uint32_t count, uint64_t *dstbuf)
char * alloc_printf(const char *format,...)
#define ERROR_TARGET_NOT_HALTED
static void binprint(struct command_invocation *cmd, const char *text, const uint8_t *buf, int size)
int target_write_u16(struct target *target, target_addr_t address, uint16_t value)
Wrapper for transport lifecycle operations.
int(* callback)(struct target *target, enum target_reset_mode reset_mode, void *priv)
static int jim_target_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
#define COMMAND_PARSE_ON_OFF(in, out)
parses an on/off command argument
Jim_Nvp * Jim_Nvp_name2value_simple(const Jim_Nvp *p, const char *name)
void target_buffer_get_u16_array(struct target *target, const uint8_t *buffer, uint32_t count, uint16_t *dstbuf)
static void target_merge_working_areas(struct target *target)
struct target_type nds32_v2_target
Holds methods for V2 targets.
#define ERROR_TARGET_UNALIGNED_ACCESS
static uint32_t le_to_h_u24(const uint8_t *buf)
static void target_buffer_set_u8(struct target *target, uint8_t *buffer, uint8_t value)
void command_print_sameline(struct command_invocation *cmd, const char *format,...)
int watchpoint_add(struct target *target, target_addr_t address, uint32_t length, enum watchpoint_rw rw, uint32_t value, uint32_t mask)
int target_call_timer_callbacks_now(void)
Invoke this to ensure that e.g.
struct target_type nds32_v3m_target
Holds methods for NDS32 V3m targets.
struct target_type arm720t_target
Holds methods for ARM720 targets.
void target_quit(void)
Free all the resources allocated by targets and the target layer.
int target_write_phys_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
int(* add_breakpoint)(struct target *target, struct breakpoint *breakpoint)
static int target_profiling(struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
int target_write_u64(struct target *target, target_addr_t address, uint64_t value)
static uint32_t le_to_h_u32(const uint8_t *buf)
int target_write_phys_u16(struct target *target, target_addr_t address, uint16_t value)
uint32_t target_buffer_get_u24(struct target *target, const uint8_t *buffer)
Name Value Pairs, aka: NVP.
struct target_type or1k_target
static COMMAND_HELPER(parse_load_image_command_CMD_ARGV, struct image *image, target_addr_t *min_address, target_addr_t *max_address)
int target_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Write count items of size bytes to the memory of target at the address given.
struct target_type cortexm_target
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
static uint32_t be_to_h_u32(const uint8_t *buf)
static struct target_timer_callback * target_timer_callbacks
int target_unregister_timer_callback(int(*callback)(void *priv), void *priv)
struct debug_msg_receiver * dbgmsg
struct target_type arm926ejs_target
Holds methods for ARM926 targets.
struct target_event_callback * next
static int new_int_array_element(Jim_Interp *interp, const char *varname, int idx, uint32_t val)
void breakpoint_remove_all(struct target *target)
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
enum target_debug_reason debug_reason
void target_buffer_set_u64_array(struct target *target, uint8_t *buffer, uint32_t count, const uint64_t *srcbuf)
int target_add_watchpoint(struct target *target, struct watchpoint *watchpoint)
Add the watchpoint for target.
int target_unregister_reset_callback(int(*callback)(struct target *target, enum target_reset_mode reset_mode, void *priv), void *priv)
struct target_type mem_ap_target
bool working_area_virt_spec
struct gdb_fileio_info * fileio_info
static void target_destroy(struct target *target)
static int no_mmu(struct target *target, int *enabled)
struct target_type arm7tdmi_target
Holds methods for ARM7TDMI targets.
static int sense_handler(void)
static int target_configure(Jim_GetOptInfo *goi, struct target *target)
int target_gdb_fileio_end(struct target *target, int retcode, int fileio_errno, bool ctrl_c)
Pass GDB file-I/O response to target after finishing host syscall.
static bool target_was_examined(struct target *target)
int(* blank_check_memory)(struct target *target, struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value)
struct target_type cortexr4_target
static int jim_target_invoke_event(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
struct target_timer_callback * next
static int jim_target_examine_deferred(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
#define ERROR_TARGET_INVALID
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly...
static int runSrstAsserted
#define LOG_INFO(expr ...)
static int jim_target_halt_gdb(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
void target_buffer_set_u24(struct target *target, uint8_t *buffer, uint32_t value)
int target_add_hybrid_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add the ContextID & IVA breakpoint for target.
This holds methods shared between all instances of a given target type.
struct target_type arm966e_target
Holds methods for ARM966 targets.
#define COMMAND_PARSE_ADDRESS(in, out)
static struct target_event_callback * target_event_callbacks
void rtos_destroy(struct target *target)
struct imagesection * sections
static int jim_target_wait_state(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
uint16_t target_buffer_get_u16(struct target *target, const uint8_t *buffer)
int context_breakpoint_add(struct target *target, uint32_t asid, uint32_t length, enum breakpoint_type type)
static int jim_target_tap_disabled(Jim_Interp *interp)
void command_print(struct command_invocation *cmd, const char *format,...)
struct target_type arm946e_target
Holds methods for ARM946 targets.
static void list_del(struct list_head *entry)
int Jim_GetOpt_Obj(Jim_GetOptInfo *goi, Jim_Obj **puthere)
Remove argv[0] from the list.
int target_free_working_area(struct target *target, struct working_area *area)
int(* write_phys_memory)(struct target *target, target_addr_t phys_address, uint32_t size, uint32_t count, const uint8_t *buffer)
bool examined
Indicates whether this target has been examined.
struct target_event_action * next
int gettimeofday(struct timeval *tv, struct timezone *tz)
int(* poll)(struct target *target)
static uint32_t be_to_h_u24(const uint8_t *buf)
int(* target_create)(struct target *target, Jim_Interp *interp)
int target_halt(struct target *target)
int target_profiling_default(struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
static int target_get_gdb_fileio_info_default(struct target *target, struct gdb_fileio_info *fileio_info)
struct target_type xscale_target
int target_arch_state(struct target *target)
void watchpoint_remove(struct target *target, target_addr_t address)
static const Jim_Nvp nvp_target_debug_reason[]
static int jim_target_reset(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
#define ERROR_TARGET_FAILURE
#define LOG_ERROR(expr ...)
struct breakpoint * breakpoints
static int identity_virt2phys(struct target *target, target_addr_t virtual, target_addr_t *physical)
#define list_for_each_entry(pos, head, member)
list_for_each_entry - iterate over list of given type : the type * to use as a loop cursor...
static void h_u64_to_be(uint8_t *buf, int64_t val)
enum target_endianness endianness
int target_examine_one(struct target *target)
Examine the specified target, letting it perform any Initialisation that requires JTAG access...
int(* callback)(void *priv)
void target_handle_md_output(struct command_invocation *cmd, struct target *target, target_addr_t address, unsigned size, unsigned count, const uint8_t *buffer)
struct target_type nds32_v3_target
Holds methods for Andes1337 targets.
int(* run_algorithm)(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_param, target_addr_t entry_point, target_addr_t exit_point, int timeout_ms, void *arch_info)
Target algorithm support.
int jtag_register_event_callback(jtag_event_handler_t callback, void *priv)
static struct FastLoad * fastload
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
#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...
struct target * all_targets
COMMAND_HANDLER(handle_target_init_command)
#define ERROR_TARGET_INIT_FAILED
int rtos_create(Jim_GetOptInfo *goi, struct target *target)
static const Jim_Nvp nvp_target_state[]
int target_poll(struct target *target)
int breakpoint_add(struct target *target, target_addr_t address, uint32_t length, enum breakpoint_type type)
struct trace * trace_info
#define ERROR_TARGET_NOT_EXAMINED
void(* deinit_target)(struct target *target)
Free all the resources allocated by the target.
static int target_write_buffer_default(struct target *target, target_addr_t address, uint32_t count, const uint8_t *buffer)
int target_request_register_commands(struct command_context *cmd_ctx)
int hybrid_breakpoint_add(struct target *target, target_addr_t address, uint32_t asid, uint32_t length, enum breakpoint_type type)
int(* add_hybrid_breakpoint)(struct target *target, struct breakpoint *breakpoint)
#define CONNECTION_LIMIT_UNLIMITED
struct target_type fa526_target
Holds methods for FA526 targets.
void breakpoint_remove(struct target *target, target_addr_t address)
int(* get_gdb_reg_list)(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
Target register access for GDB.
int target_read_u8(struct target *target, target_addr_t address, uint8_t *value)
static LIST_HEAD(target_reset_callback_list)
bool get_target_reset_nag(void)
void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, const uint32_t *srcbuf)
static int runPowerRestore
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
static void h_u24_to_le(uint8_t *buf, int val)
int target_wait_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, uint32_t exit_point, int timeout_ms, void *arch_info)
Waits for an algorithm started with target_start_algorithm() to complete.
int timeval_compare(const struct timeval *x, const struct timeval *y)
bool target_has_event_action(struct target *target, enum target_event event)
Returns true only if the target has a handler for the specified event.
int(* examine)(struct target *target)
This method is used to perform target setup that requires JTAG access.
int(* virt2phys)(struct target *target, target_addr_t address, target_addr_t *physical)
void target_buffer_set_u32(struct target *target, uint8_t *buffer, uint32_t value)
static int target_init(struct command_context *cmd_ctx)
struct reg_cache * reg_cache
#define ERROR_COMMAND_SYNTAX_ERROR
#define LOG_WARNING(expr ...)
static const char * target_name(struct target *target)
Returns the instance-specific name of the specified target.
static uint64_t be_to_h_u64(const uint8_t *buf)
struct target_event_action * event_action
void target_buffer_get_u32_array(struct target *target, const uint8_t *buffer, uint32_t count, uint32_t *dstbuf)
unsigned int num_sections
static uint16_t le_to_h_u16(const uint8_t *buf)
int(* set)(struct reg *reg, uint8_t *buf)
float duration_elapsed(const struct duration *duration)
enum target_timer_type type
int(* hit_watchpoint)(struct target *target, struct watchpoint **hit_watchpoint)
static void h_u64_to_le(uint8_t *buf, int64_t val)
int Jim_GetOpt_Wide(Jim_GetOptInfo *goi, jim_wide *puthere)
Remove argv[0] as wide.
struct target_type arm920t_target
Holds methods for ARM920 targets.
int(* wait_algorithm)(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_param, target_addr_t exit_point, int timeout_ms, void *arch_info)
static const Jim_Nvp nvp_reset_modes[]
struct jtag_tap * jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *obj)
Upper level NOR flash interfaces.
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
int str_to_buf(const char *str, unsigned str_len, void *_buf, unsigned buf_len, unsigned radix)
bool jtag_poll_get_enabled(void)
Return flag reporting whether JTAG polling is disallowed.
int target_call_reset_callbacks(struct target *target, enum target_reset_mode reset_mode)
int image_calculate_checksum(const uint8_t *buffer, uint32_t nbytes, uint32_t *checksum)
int timeval_add_time(struct timeval *result, long sec, long usec)
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
struct target * get_current_target(struct command_context *cmd_ctx)
#define ERROR_COMMAND_CLOSE_CONNECTION
bool working_area_phys_spec
int(* remove_breakpoint)(struct target *target, struct breakpoint *breakpoint)
int(* get_gdb_fileio_info)(struct target *target, struct gdb_fileio_info *fileio_info)
static int default_examine(struct target *target)
static int target_gdb_fileio_end_default(struct target *target, int retcode, int fileio_errno, bool ctrl_c)
int(* deassert_reset)(struct target *target)
The implementation is responsible for polling the target such that target->state reflects the state c...
static void h_u16_to_le(uint8_t *buf, int val)
int Jim_GetOpt_Nvp(Jim_GetOptInfo *goi, const Jim_Nvp *nvp, Jim_Nvp **puthere)
Remove argv[0] as NVP.
int target_run_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_param, uint32_t entry_point, uint32_t exit_point, int timeout_ms, void *arch_info)
Downloads a target-specific native code algorithm to the target, and executes it. ...
struct target_type aarch64_target
const char * target_get_gdb_arch(struct target *target)
Obtain the architecture for GDB.
int target_register_trace_callback(int(*callback)(struct target *target, size_t len, uint8_t *data, void *priv), void *priv)
int target_register_event_callback(int(*callback)(struct target *target, enum target_event event, void *priv), void *priv)
uint32_t backup_working_area
void image_close(struct image *image)
int(* soft_reset_halt)(struct target *target)
int(* mmu)(struct target *target, int *enabled)
struct target_type esirisc_target
struct target_type cortexa_target
struct target_type feroceon_target
int target_hit_watchpoint(struct target *target, struct watchpoint **hit_watchpoint)
Find out the just hit watchpoint for target.
bool enabled
Is this TAP currently enabled?
struct target_type testee_target
struct target * current_target_override
float duration_kbps(const struct duration *duration, size_t count)
struct transport * get_current_transport(void)
Returns the transport currently being used by this debug or programming session.
uint32_t target_get_working_area_avail(struct target *target)
#define ERROR_TARGET_NOT_RUNNING
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
const struct rtos_type * type
static int default_check_reset(struct target *target)
int image_open(struct image *image, const char *url, const char *type_string)
#define ERROR_TARGET_TIMEOUT
int target_get_gdb_reg_list_noread(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
Obtain the registers for GDB, but don't read register values from the target.
size_t size
Size of the control block search area.
int target_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
Step the target.
struct target_type dsp563xx_target
Holds methods for DSP563XX targets.
static const Jim_Nvp nvp_target_endian[]
struct command * command_find_in_context(struct command_context *cmd_ctx, const char *name)
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
const char * usage
a string listing the options and arguments, required or optional
int(* halt)(struct target *target)
uint32_t working_area_size
static uint16_t be_to_h_u16(const uint8_t *buf)
const char * target_type_name(struct target *target)
Get the target type name.
int target_write_phys_u8(struct target *target, target_addr_t address, uint8_t value)
struct target_type dsp5680xx_target
Holds methods for dsp5680xx targets.
#define DEFAULT_HALT_TIMEOUT
int jtag_unregister_event_callback(jtag_event_handler_t callback, void *priv)
const struct command_registration * commands
char *(* ps_command)(struct target *target)
target_addr_t base_address
int target_write_u8(struct target *target, target_addr_t address, uint8_t value)
int(* get_gdb_reg_list_noread)(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
Same as get_gdb_reg_list, but doesn't read the register values.
static void h_u24_to_be(uint8_t *buf, int val)
int(* resume)(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
struct target_type mips_mips64_target
int trace_register_commands(struct command_context *cmd_ctx)
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
struct target_type * type
static void target_split_working_area(struct working_area *area, uint32_t size)
enum breakpoint_type type
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
static int target_free_working_area_restore(struct target *target, struct working_area *area, int restore)
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned first, unsigned num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word...
int target_run_flash_async_algorithm(struct target *target, const uint8_t *buffer, uint32_t count, int block_size, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, uint32_t buffer_start, uint32_t buffer_size, uint32_t entry_point, uint32_t exit_point, void *arch_info)
Streams data to a circular buffer on target intended for consumption by code running asynchronously o...
struct working_area * next
int target_register_reset_callback(int(*callback)(struct target *target, enum target_reset_mode reset_mode, void *priv), void *priv)
struct target_type quark_d20xx_target
target_addr_t working_area_virt
static void write_gmon(uint32_t *samples, uint32_t sampleNum, const char *filename, bool with_range, uint32_t start_address, uint32_t end_address, struct target *target, uint32_t duration_ms)
static int jim_target_poll(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static void h_u32_to_be(uint8_t *buf, int val)
void Jim_GetOpt_NvpUnknown(Jim_GetOptInfo *goi, const Jim_Nvp *nvptable, int hadprefix)
Create an appropriate error message for an NVP.
static void writeData(FILE *f, const void *data, size_t len)
struct command_context * current_command_context(Jim_Interp *interp)
struct target * current_target
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
Jim_Nvp * Jim_Nvp_value2name_simple(const Jim_Nvp *p, int value)
static int jtag_enable_callback(enum jtag_event event, void *priv)
static const struct command_registration target_exec_command_handlers[]
struct command_context * ctx
static int target_read_buffer_default(struct target *target, target_addr_t address, uint32_t count, uint8_t *buffer)
unsigned(* address_bits)(struct target *target)
int(* add_context_breakpoint)(struct target *target, struct breakpoint *breakpoint)
struct backoff_timer backoff
static int jim_target_types(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int target_init_one(struct command_context *cmd_ctx, struct target *target)
static int jim_target_halt(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static const struct command_registration target_instance_command_handlers[]
int(* read_memory)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Target memory read callback.
int Jim_GetOpt_Setup(Jim_GetOptInfo *p, Jim_Interp *interp, int argc, Jim_Obj *const *argv)
GetOpt - how to.
struct target_type riscv_target
uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer)
int target_add_context_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add the ContextID breakpoint for target.
int(* step)(struct target *target, int current, target_addr_t address, int handle_breakpoints)
static int target_register_user_commands(struct command_context *cmd_ctx)
int(* read_buffer)(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
struct target_type arcv2_target
int target_unregister_event_callback(int(*callback)(struct target *target, enum target_event event, void *priv), void *priv)
static int handle_target(void *priv)
bool is_jtag_poll_safe(void)
Return true if it's safe for a background polling task to access the JTAG scan chain.
static int jim_target_configure(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
void alive_sleep(uint64_t ms)
static const int polling_interval
static Jim_Nvp nvp_config_opts[]
int(* checksum_memory)(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
int target_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
Make the target (re)start executing using its saved execution context (possibly with some modificatio...
int fileio_close(struct fileio *fileio)
struct target_type mips_m4k_target
struct target * get_current_target_or_null(struct command_context *cmd_ctx)
int(* callback)(struct target *target, enum target_event event, void *priv)
static int target_process_reset(struct command_invocation *cmd, enum target_reset_mode reset_mode)
int(* start_algorithm)(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_param, target_addr_t entry_point, target_addr_t exit_point, void *arch_info)
The JTAG interface can be implemented with a software or hardware fifo.
int target_alloc_working_area_try(struct target *target, uint32_t size, struct working_area **area)
const char * target_event_name(enum target_event event)
Return the name of a target event enumeration value.
int target_start_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, uint32_t entry_point, uint32_t exit_point, void *arch_info)
Executes a target-specific native code algorithm and leaves it running.
static uint64_t le_to_h_u64(const uint8_t *buf)
int target_call_trace_callbacks(struct target *target, size_t len, uint8_t *data)
static const struct command_registration target_subcommand_handlers[]
const char * debug_reason_name(struct target *t)
static int target_timer_callback_periodic_restart(struct target_timer_callback *cb, struct timeval *now)
int target_remove_breakpoint(struct target *target, struct breakpoint *breakpoint)
Remove the breakpoint for target.
static int target_create(Jim_GetOptInfo *goi)
struct target_type stm8_target
int target_unregister_trace_callback(int(*callback)(struct target *target, size_t len, uint8_t *data, void *priv), void *priv)
struct target_list * next
static void free_fastload(void)
struct watchpoint * watchpoints
int(* check_reset)(struct target *target)
int target_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Read count items of size bytes from the memory of target at the address given.
static int jim_target_was_examined(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int fileio_write(struct fileio *fileio, size_t size, const void *buffer, size_t *size_written)
int command_run_line(struct command_context *context, char *line)
void target_buffer_set_u64(struct target *target, uint8_t *buffer, uint64_t value)
#define ERROR_TARGET_TRANSLATION_FAULT
static int find_target(struct command_invocation *cmd, const char *name)
int target_call_event_callbacks(struct target *target, enum target_event event)
int target_run_read_async_algorithm(struct target *target, uint8_t *buffer, uint32_t count, int block_size, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, uint32_t buffer_start, uint32_t buffer_size, uint32_t entry_point, uint32_t exit_point, void *arch_info)
This routine is a wrapper for asynchronous algorithms.
struct target_type hla_target
int target_register_commands(struct command_context *cmd_ctx)
int target_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fileio_info)
Obtain file-I/O information from target for GDB to do syscall.
int(* target_write_fn)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
#define LOG_DEBUG(expr ...)
bool target_supports_gdb_connection(struct target *target)
Check if target allows GDB connections.
int(* gdb_fileio_end)(struct target *target, int retcode, int fileio_errno, bool ctrl_c)
const char *(* get_gdb_arch)(struct target *target)
Target architecture for GDB.
int Jim_GetOpt_String(Jim_GetOptInfo *goi, const char **puthere, int *len)
Remove argv[0] as string.
int target_register_timer_callback(int(*callback)(void *priv), unsigned int time_ms, enum target_timer_type type, void *priv)
The period is very approximate, the callback can happen much more often or much more rarely than spec...
int fileio_open(struct fileio **fileio, const char *url, enum fileio_access access_type, enum fileio_type type)
unsigned target_address_bits(struct target *target)
Return the number of address bits this target supports.
int(* read_phys_memory)(struct target *target, target_addr_t phys_address, uint32_t size, uint32_t count, uint8_t *buffer)
static int jim_target_examine(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int(* write_buffer)(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
#define ERROR_TARGET_DATA_ABORT
static int handle_bp_command_list(struct command_invocation *cmd)
struct target * get_target_by_num(int num)
static int target_soft_reset_halt(struct target *target)
int target_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add the breakpoint for target.
static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static const struct command_registration target_command_handlers[]
static const char * target_strerror_safe(int err)
struct target_type arm11_target
Holds methods for ARM11xx targets.
static int get_int_array_element(Jim_Interp *interp, const char *varname, int idx, uint32_t *val)
static int runPowerDropout
struct working_area ** user
static void target_reset_examined(struct target *target)
Reset the examined flag for the given target.
int(* assert_reset)(struct target *target)
int image_read_section(struct image *image, int section, uint32_t offset, uint32_t size, uint8_t *buffer, size_t *size_read)
struct target_type avr32_ap7k_target
int(* get)(struct reg *reg)
int rtos_smp_init(struct target *target)
uint64_t target_buffer_get_u64(struct target *target, const uint8_t *buffer)
struct semihosting * semihosting
int duration_start(struct duration *duration)
Update the duration->start field to start the duration measurement.
int target_blank_check_memory(struct target *target, struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value)
int(* callback)(struct target *target, size_t len, uint8_t *data, void *priv)
static int target_mem2array(Jim_Interp *interp, struct target *target, int argc, Jim_Obj *const *argv)
int target_remove_watchpoint(struct target *target, struct watchpoint *watchpoint)
Remove the watchpoint for target.
static bool target_reset_nag