52 #define DEFAULT_HALT_TIMEOUT 5000
59 int argc, Jim_Obj *
const *argv);
61 int argc, Jim_Obj *
const *argv);
66 int fileio_errno,
bool ctrl_c);
170 { .name =
NULL, .value = -1 }
185 { .value = -1, .name =
NULL }
248 { .name =
NULL, .value = -1 }
257 { .name =
NULL, .value = -1 },
270 { .name =
NULL, .value = -1 },
278 { .name =
NULL, .value = -1 },
286 { .name =
NULL, .value = -1 },
297 cp =
"(*BUG*unknown*BUG*)";
308 cp =
"(*BUG*unknown*BUG*)";
312 cp =
"examine deferred";
322 LOG_ERROR(
"Invalid target event: %d", (
int)(event));
323 cp =
"(*BUG*unknown*BUG*)";
333 LOG_ERROR(
"Invalid target reset mode: %d", (
int)(reset_mode));
334 cp =
"(*BUG*unknown*BUG*)";
447 for (i = 0; i <
count; i++)
455 for (i = 0; i <
count; i++)
463 for (i = 0; i <
count; i++)
471 for (i = 0; i <
count; i++)
479 for (i = 0; i <
count; i++)
487 for (i = 0; i <
count; i++)
508 if (parse_uint(
id, &num) !=
ERROR_OK)
513 LOG_WARNING(
"use '%s' as target identifier, not '%u'",
541 LOG_ERROR(
"BUG: current_target out of bounds");
576 LOG_INFO(
"Halt timed out, wake up GDB.");
635 int handle_breakpoints,
int debug_execution)
692 sprintf(buf,
"ocd_process_reset %s", n->
name);
693 retval = Jim_Eval(
cmd->ctx->interp, buf);
697 if (retval != JIM_OK) {
698 Jim_MakeErrorMessage(
cmd->ctx->interp);
821 LOG_ERROR(
"Target %s does not support soft_reset_halt",
847 int num_mem_params,
struct mem_param *mem_params,
859 LOG_ERROR(
"Target type '%s' does not support %s",
866 num_mem_params, mem_params,
868 entry_point, exit_point, timeout_ms,
arch_info);
888 int num_mem_params,
struct mem_param *mem_params,
889 int num_reg_params,
struct reg_param *reg_params,
900 LOG_ERROR(
"Target type '%s' does not support %s",
905 LOG_ERROR(
"Target is already running an algorithm");
911 num_mem_params, mem_params,
912 num_reg_params, reg_params,
932 int num_mem_params,
struct mem_param *mem_params,
933 int num_reg_params,
struct reg_param *reg_params,
940 LOG_ERROR(
"Target type '%s' does not support %s",
945 LOG_ERROR(
"Target is not running an algorithm");
950 num_mem_params, mem_params,
951 num_reg_params, reg_params,
1004 const uint8_t *
buffer, uint32_t
count,
int block_size,
1005 int num_mem_params,
struct mem_param *mem_params,
1006 int num_reg_params,
struct reg_param *reg_params,
1007 uint32_t buffer_start, uint32_t buffer_size,
1008 uint32_t entry_point, uint32_t exit_point,
void *
arch_info)
1013 const uint8_t *buffer_orig =
buffer;
1017 uint32_t wp_addr = buffer_start;
1018 uint32_t rp_addr = buffer_start + 4;
1019 uint32_t fifo_start_addr = buffer_start + 8;
1020 uint32_t fifo_end_addr = buffer_start + buffer_size;
1022 uint32_t wp = fifo_start_addr;
1023 uint32_t rp = fifo_start_addr;
1037 num_reg_params, reg_params,
1043 LOG_ERROR(
"error starting target flash write algorithm");
1051 LOG_ERROR(
"failed to get read pointer");
1055 LOG_DEBUG(
"offs 0x%zx count 0x%" PRIx32
" wp 0x%" PRIx32
" rp 0x%" PRIx32,
1059 LOG_ERROR(
"flash write algorithm aborted by target");
1064 if (!
IS_ALIGNED(rp - fifo_start_addr, block_size) || rp < fifo_start_addr || rp >= fifo_end_addr) {
1065 LOG_ERROR(
"corrupted fifo read pointer 0x%" PRIx32, rp);
1072 uint32_t thisrun_bytes;
1074 thisrun_bytes = rp - wp - block_size;
1075 else if (rp > fifo_start_addr)
1076 thisrun_bytes = fifo_end_addr - wp;
1078 thisrun_bytes = fifo_end_addr - wp - block_size;
1080 if (thisrun_bytes == 0) {
1090 LOG_ERROR(
"timeout waiting for algorithm, a target reset is recommended");
1100 if (thisrun_bytes >
count * block_size)
1101 thisrun_bytes =
count * block_size;
1104 if (thisrun_bytes >= 16)
1105 thisrun_bytes -= (rp + thisrun_bytes) & 0x03;
1114 count -= thisrun_bytes / block_size;
1115 wp += thisrun_bytes;
1116 if (wp >= fifo_end_addr)
1117 wp = fifo_start_addr;
1134 num_reg_params, reg_params,
1140 LOG_ERROR(
"error waiting for target flash write algorithm");
1147 if (retval ==
ERROR_OK && rp == 0) {
1148 LOG_ERROR(
"flash write algorithm aborted by target");
1158 int num_mem_params,
struct mem_param *mem_params,
1159 int num_reg_params,
struct reg_param *reg_params,
1160 uint32_t buffer_start, uint32_t buffer_size,
1161 uint32_t entry_point, uint32_t exit_point,
void *
arch_info)
1166 const uint8_t *buffer_orig =
buffer;
1170 uint32_t wp_addr = buffer_start;
1171 uint32_t rp_addr = buffer_start + 4;
1172 uint32_t fifo_start_addr = buffer_start + 8;
1173 uint32_t fifo_end_addr = buffer_start + buffer_size;
1175 uint32_t wp = fifo_start_addr;
1176 uint32_t rp = fifo_start_addr;
1190 num_reg_params, reg_params,
1196 LOG_ERROR(
"error starting target flash read algorithm");
1203 LOG_ERROR(
"failed to get write pointer");
1207 LOG_DEBUG(
"offs 0x%zx count 0x%" PRIx32
" wp 0x%" PRIx32
" rp 0x%" PRIx32,
1211 LOG_ERROR(
"flash read algorithm aborted by target");
1216 if (!
IS_ALIGNED(wp - fifo_start_addr, block_size) || wp < fifo_start_addr || wp >= fifo_end_addr) {
1217 LOG_ERROR(
"corrupted fifo write pointer 0x%" PRIx32, wp);
1223 uint32_t thisrun_bytes;
1225 thisrun_bytes = wp - rp;
1227 thisrun_bytes = fifo_end_addr - rp;
1229 if (thisrun_bytes == 0) {
1239 LOG_ERROR(
"timeout waiting for algorithm, a target reset is recommended");
1249 if (thisrun_bytes >
count * block_size)
1250 thisrun_bytes =
count * block_size;
1253 if (thisrun_bytes >= 16)
1254 thisrun_bytes -= (rp + thisrun_bytes) & 0x03;
1263 count -= thisrun_bytes / block_size;
1264 rp += thisrun_bytes;
1265 if (rp >= fifo_end_addr)
1266 rp = fifo_start_addr;
1284 num_reg_params, reg_params,
1290 LOG_ERROR(
"error waiting for target flash write algorithm");
1297 if (retval ==
ERROR_OK && wp == 0) {
1298 LOG_ERROR(
"flash read algorithm aborted by target");
1438 struct reg **reg_list[],
int *reg_list_size,
1449 reg_list_size, reg_class);
1460 struct reg **reg_list[],
int *reg_list_size,
1465 reg_list_size, reg_class) ==
ERROR_OK)
1537 uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
1540 num_samples, seconds);
1554 if (!
type->check_reset)
1557 assert(
type->init_target);
1559 int retval =
type->init_target(cmd_ctx,
target);
1569 if (!
type->virt2phys) {
1578 if (
type->write_phys_memory ||
type->read_phys_memory ||
type->virt2phys)
1582 type->write_phys_memory =
type->write_memory;
1583 type->read_phys_memory =
type->read_memory;
1638 static bool target_initialized;
1639 if (target_initialized) {
1640 LOG_INFO(
"'target init' has already been called");
1643 target_initialized =
true;
1670 while ((*callbacks_p)->next)
1671 callbacks_p = &((*callbacks_p)->next);
1672 callbacks_p = &((*callbacks_p)->next);
1676 (*callbacks_p)->callback =
callback;
1677 (*callbacks_p)->priv =
priv;
1678 (*callbacks_p)->next =
NULL;
1693 LOG_ERROR(
"error allocating buffer for reset callback entry");
1706 size_t len, uint8_t *data,
void *
priv),
void *
priv)
1715 LOG_ERROR(
"error allocating buffer for trace callback entry");
1736 while ((*callbacks_p)->next)
1737 callbacks_p = &((*callbacks_p)->next);
1738 callbacks_p = &((*callbacks_p)->next);
1742 (*callbacks_p)->callback =
callback;
1743 (*callbacks_p)->type =
type;
1744 (*callbacks_p)->time_ms =
time_ms;
1745 (*callbacks_p)->removed =
false;
1750 (*callbacks_p)->priv =
priv;
1751 (*callbacks_p)->next =
NULL;
1799 size_t len, uint8_t *data,
void *
priv),
void *
priv)
1843 LOG_DEBUG(
"target event %i (%s) for core %s", event,
1862 LOG_DEBUG(
"target reset %i (%s)", reset_mode,
1901 static bool callback_processing;
1904 if (callback_processing)
1907 callback_processing =
true;
1923 if ((*callback)->removed) {
1930 bool call_it = (*callback)->callback &&
1932 now >= (*callback)->when);
1943 callback_processing =
false;
1980 assert(size <= area->
size);
1983 if (size < area->
size) {
1994 new_wa->
free =
true;
1996 area->
next = new_wa;
2011 while (c && c->
next) {
2048 LOG_DEBUG(
"MMU disabled, using physical "
2053 LOG_ERROR(
"No working memory available. "
2054 "Specify -work-area-phys to target.");
2064 LOG_ERROR(
"No working memory available. "
2065 "Specify -work-area-virt to target.");
2078 new_wa->
free =
true;
2135 LOG_WARNING(
"not enough working area available(requested %"PRIu32
")",
size);
2157 if (!area || area->
free)
2236 uint32_t max_size = 0;
2351 int retcode,
int fileio_errno,
bool ctrl_c)
2357 uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
2364 LOG_INFO(
"Starting profiling. Halting and resuming the"
2365 " target as often as we can...");
2367 uint32_t sample_count = 0;
2376 samples[sample_count++] = t;
2385 LOG_INFO(
"Target not halted or running");
2395 LOG_INFO(
"Profiling completed. %" PRIu32
" samples.", sample_count);
2400 *num_samples = sample_count;
2421 if ((address +
size - 1) < address) {
2441 size < data_bytes && count >=
size * 2 + (address &
size);
2443 if (address &
size) {
2486 if ((address +
size - 1) < address) {
2505 size < data_bytes && count >=
size * 2 + (address &
size);
2507 if (address &
size) {
2538 uint32_t checksum = 0;
2552 LOG_ERROR(
"error allocating buffer for section (%" PRIu32
" bytes)",
size);
2562 for (i = 0; i < (
size/
sizeof(uint32_t)); i++) {
2563 uint32_t target_data;
2579 uint8_t erased_value)
2594 uint8_t value_buf[8];
2618 uint8_t value_buf[4];
2642 uint8_t value_buf[2];
2689 uint8_t value_buf[8];
2710 uint8_t value_buf[4];
2731 uint8_t value_buf[2];
2770 uint8_t value_buf[8];
2791 uint8_t value_buf[4];
2812 uint8_t value_buf[2];
2857 "can't be the current target\n",
2863 if (
cmd->ctx->current_target_override)
2864 cmd->ctx->current_target_override =
target;
2883 command_print(
CMD,
"-- ------------------ ---------- ------ ------------------ ------------");
2891 state =
"tap-disabled";
2898 "%2d%c %-18s %-10s %-6s %-18s %s",
2925 static int prev_srst_asserted;
2926 static int prev_power_dropout;
2938 static int64_t last_power;
2939 bool wait_more = last_power + 2000 > current;
2942 last_power = current;
2949 int srst_deasserted;
2952 static int64_t last_srst;
2953 wait_more = last_srst + 2000 > current;
2954 if (srst_deasserted && !wait_more) {
2956 last_srst = current;
2965 if (srst_deasserted || power_restored) {
2978 Jim_Interp *interp = (Jim_Interp *)
priv;
2987 static int recursive;
2995 int did_something = 0;
2997 LOG_INFO(
"srst asserted detected, running srst_asserted proc.");
2998 Jim_Eval(interp,
"srst_asserted");
3002 Jim_Eval(interp,
"srst_deasserted");
3006 LOG_INFO(
"Power dropout detected, running power_dropout proc.");
3007 Jim_Eval(interp,
"power_dropout");
3011 Jim_Eval(interp,
"power_restore");
3015 if (did_something) {
3074 LOG_USER(
"Examination failed, GDB will be halted. Polling again in %dms",
3099 unsigned int count = 0;
3115 "(%i) %s (/%" PRIu32
"): 0x%s%s",
3128 cache = cache->
next;
3140 unsigned int count = 0;
3143 for (i = 0; i < cache->
num_regs; i++) {
3144 if (
count++ == num) {
3151 cache = cache->
next;
3156 "has only %i registers (0 - %i)", num,
count,
count - 1);
3255 int retval = parse_uint(
CMD_ARGV[0], &ms);
3273 int64_t then = 0, cur;
3293 if ((cur-then) > ms) {
3294 LOG_ERROR(
"timed out while waiting for target %s",
3316 unsigned wait_local;
3317 retval = parse_uint(
CMD_ARGV[0], &wait_local);
3349 reset_mode = n->
value;
3403 const unsigned line_bytecnt = 32;
3404 unsigned line_modulo = line_bytecnt /
size;
3406 char output[line_bytecnt * 4 + 1];
3407 unsigned output_len = 0;
3409 const char *value_fmt;
3412 value_fmt =
"%16.16"PRIx64
" ";
3415 value_fmt =
"%8.8"PRIx64
" ";
3418 value_fmt =
"%4.4"PRIx64
" ";
3421 value_fmt =
"%2.2"PRIx64
" ";
3429 for (
unsigned i = 0; i <
count; i++) {
3430 if (i % line_modulo == 0) {
3431 output_len += snprintf(
output + output_len,
3432 sizeof(
output) - output_len,
3434 (address + (i *
size)));
3438 const uint8_t *value_ptr =
buffer + i *
size;
3452 output_len += snprintf(
output + output_len,
3453 sizeof(
output) - output_len,
3456 if ((i % line_modulo == line_modulo - 1) || (i ==
count - 1)) {
3486 bool physical = strcmp(
CMD_ARGV[0],
"phys") == 0;
3507 LOG_ERROR(
"Failed to allocate md read buffer");
3535 const unsigned chunk_size = 16384;
3536 uint8_t *target_buf = malloc(chunk_size * data_size);
3542 for (
unsigned i = 0; i < chunk_size; i++) {
3543 switch (data_size) {
3563 for (
unsigned x = 0; x < c; x += chunk_size) {
3566 if (current > chunk_size)
3567 current = chunk_size;
3568 retval = fn(
target, address + x * data_size, data_size, current, target_buf);
3584 bool physical = strcmp(
CMD_ARGV[0],
"phys") == 0;
3630 if (CMD_ARGC < 1 || CMD_ARGC > 5)
3650 *max_address += *min_address;
3653 if (*min_address > *max_address)
3663 uint32_t image_size;
3669 &
image, &min_address, &max_address);
3687 "error allocating buffer for section (%d bytes)",
3700 uint32_t
length = buf_cnt;
3733 "in %fs (%0.3f KiB/s)", image_size,
3747 int retval, retvaltemp;
3758 uint32_t buf_size = (
size > 4096) ? 4096 :
size;
3759 buffer = malloc(buf_size);
3772 size_t size_written;
3773 uint32_t this_run_size = (
size > buf_size) ? buf_size :
size;
3782 size -= this_run_size;
3783 address += this_run_size;
3794 "dumped %zu bytes in %fs (%0.3f KiB/s)", filesize,
3815 uint32_t image_size;
3817 uint32_t checksum = 0;
3818 uint32_t mem_checksum = 0;
3858 "error allocating buffer for section (%" PRIu32
" bytes)",
3887 if (checksum != mem_checksum) {
3892 LOG_ERROR(
"checksum mismatch - attempting binary compare");
3894 data = malloc(buf_cnt);
3899 for (t = 0; t < buf_cnt; t++) {
3900 if (data[t] !=
buffer[t]) {
3902 "diff %d address 0x%08x. Was 0x%02x instead of 0x%02x",
3907 if (diffs++ >= 127) {
3926 image_size += buf_cnt;
3935 "in %fs (%0.3f KiB/s)", image_size,
4006 }
else if (
addr == 0) {
4008 LOG_ERROR(
"Context breakpoint not available");
4018 LOG_ERROR(
"Hybrid breakpoint not available");
4047 if (strcmp(
CMD_ARGV[2],
"hw") == 0) {
4053 }
else if (strcmp(
CMD_ARGV[2],
"hw_ctx") == 0) {
4101 ", len: 0x%8.8" PRIx32
4102 ", r/w/a: %i, value: 0x%8.8" PRIx32
4103 ", mask: 0x%8.8" PRIx32,
4117 uint32_t data_value = 0x0;
4118 uint32_t data_mask = 0xffffffff;
4153 data_value, data_mask);
4155 LOG_ERROR(
"Failure setting watchpoints");
4199 size_t written = fwrite(data, 1, len, f);
4201 LOG_ERROR(
"failed to write %zu bytes: %s", len, strerror(errno));
4220 static void write_gmon(uint32_t *samples, uint32_t sample_num,
const char *filename,
bool with_range,
4221 uint32_t start_address, uint32_t end_address,
struct target *
target, uint32_t duration_ms)
4224 FILE *f = fopen(filename,
"w");
4240 min = start_address;
4245 for (i = 0; i < sample_num; i++) {
4246 if (min > samples[i])
4248 if (max < samples[i])
4254 if (max < UINT32_MAX)
4258 while ((max - min) < 2) {
4259 if (max < UINT32_MAX)
4266 uint32_t address_space = max - min;
4270 static const uint32_t max_buckets = 128 * 1024;
4271 uint32_t num_buckets = address_space /
sizeof(
UNIT);
4272 if (num_buckets > max_buckets)
4273 num_buckets = max_buckets;
4274 int *buckets = malloc(
sizeof(
int) * num_buckets);
4279 memset(buckets, 0,
sizeof(
int) * num_buckets);
4280 for (i = 0; i < sample_num; i++) {
4281 uint32_t address = samples[i];
4283 if ((address < min) || (max <= address))
4286 long long a = address - min;
4287 long long b = num_buckets;
4288 long long c = address_space;
4289 int index_t = (a * b) / c;
4297 float sample_rate = sample_num / (duration_ms / 1000.0);
4300 for (i = 0; i < (15-strlen(
"seconds")); i++)
4306 char *data = malloc(2 * num_buckets);
4308 for (i = 0; i < num_buckets; i++) {
4313 data[i * 2] = val&0xff;
4314 data[i * 2 + 1] = (val >> 8) & 0xff;
4334 const uint32_t MAX_PROFILE_SAMPLE_NUM = 10000;
4336 uint32_t num_of_samples;
4342 uint32_t start_address = 0;
4343 uint32_t end_address = 0;
4344 bool with_range =
false;
4349 if (start_address > end_address || (end_address - start_address) < 2) {
4355 uint32_t *samples = malloc(
sizeof(uint32_t) * MAX_PROFILE_SAMPLE_NUM);
4357 LOG_ERROR(
"No memory to store samples.");
4368 &num_of_samples,
offset);
4373 uint32_t duration_ms =
timeval_ms() - timestart_ms;
4375 assert(num_of_samples <= MAX_PROFILE_SAMPLE_NUM);
4408 with_range, start_address, end_address,
target, duration_ms);
4418 Jim_Obj *obj_name, *obj_val;
4425 obj_name = Jim_NewStringObj(interp, namebuf, -1);
4426 jim_wide wide_val = val;
4427 obj_val = Jim_NewWideObj(interp, wide_val);
4428 if (!obj_name || !obj_val) {
4433 Jim_IncrRefCount(obj_name);
4434 Jim_IncrRefCount(obj_val);
4435 result = Jim_SetVariable(interp, obj_name, obj_val);
4436 Jim_DecrRefCount(interp, obj_name);
4437 Jim_DecrRefCount(interp, obj_val);
4447 LOG_WARNING(
"DEPRECATED! use 'read_memory' not 'mem2array'");
4455 if (argc < 4 || argc > 5) {
4456 Jim_WrongNumArgs(interp, 0, argv,
"varname width addr nelems [phys]");
4461 const char *varname = Jim_GetString(argv[0],
NULL);
4465 e = Jim_GetLong(interp, argv[1], &l);
4468 const unsigned int width_bits = l;
4470 if (width_bits != 8 &&
4474 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4475 Jim_AppendStrings(interp, Jim_GetResult(interp),
4476 "Invalid width param. Must be one of: 8, 16, 32 or 64.",
NULL);
4479 const unsigned int width = width_bits / 8;
4483 e = Jim_GetWide(interp, argv[2], &wide_addr);
4489 e = Jim_GetLong(interp, argv[3], &l);
4495 bool is_phys =
false;
4498 const char *phys = Jim_GetString(argv[4], &str_len);
4499 if (!strncmp(phys,
"phys", str_len))
4507 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4508 Jim_AppendStrings(interp, Jim_GetResult(interp),
"mem2array: zero width read?",
NULL);
4512 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4513 Jim_AppendStrings(interp, Jim_GetResult(interp),
"mem2array: addr + len - wraps to zero?",
NULL);
4517 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4518 Jim_AppendStrings(interp, Jim_GetResult(interp),
4519 "mem2array: too large read request, exceeds 64K items",
NULL);
4530 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4531 sprintf(buf,
"mem2array address: " TARGET_ADDR_FMT " is not aligned for %" PRIu32
" byte reads",
4534 Jim_AppendStrings(interp, Jim_GetResult(interp), buf,
NULL);
4543 const size_t buffersize = 4096;
4544 uint8_t *
buffer = malloc(buffersize);
4552 const unsigned int max_chunk_len = buffersize /
width;
4553 const size_t chunk_len =
MIN(len, max_chunk_len);
4566 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4567 Jim_AppendStrings(interp, Jim_GetResult(interp),
"mem2array: cannot read memory",
NULL);
4571 for (
size_t i = 0; i < chunk_len ; i++, idx++) {
4596 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4602 Jim_Obj *
const *argv)
4611 if (argc < 4 || argc > 5) {
4612 Jim_WrongNumArgs(interp, 1, argv,
"address width count ['phys']");
4619 e = Jim_GetWide(interp, argv[1], &wide_addr);
4628 e = Jim_GetLong(interp, argv[2], &l);
4633 const unsigned int width_bits = l;
4636 e = Jim_GetLong(interp, argv[3], &l);
4644 bool is_phys =
false;
4647 const char *phys = Jim_GetString(argv[4],
NULL);
4649 if (strcmp(phys,
"phys")) {
4650 Jim_SetResultFormatted(interp,
"invalid argument '%s', must be 'phys'", phys);
4657 switch (width_bits) {
4664 Jim_SetResultString(interp,
"invalid width, must be 8, 16, 32 or 64", -1);
4668 const unsigned int width = width_bits / 8;
4671 Jim_SetResultString(interp,
"read_memory: addr + count wraps to zero", -1);
4675 if (
count > 65536) {
4676 Jim_SetResultString(interp,
"read_memory: too large read request, exeeds 64K elements", -1);
4681 assert(cmd_ctx !=
NULL);
4684 const size_t buffersize = 4096;
4685 uint8_t *
buffer = malloc(buffersize);
4692 Jim_Obj *result_list = Jim_NewListObj(interp,
NULL, 0);
4693 Jim_IncrRefCount(result_list);
4696 const unsigned int max_chunk_len = buffersize /
width;
4697 const size_t chunk_len =
MIN(
count, max_chunk_len);
4708 addr, width_bits, chunk_len);
4709 Jim_SetResultString(interp,
"read_memory: failed to read memory", -1);
4714 for (
size_t i = 0; i < chunk_len ; i++) {
4733 snprintf(value_buf,
sizeof(value_buf),
"0x%" PRIx64, v);
4735 Jim_ListAppendElement(interp, result_list,
4736 Jim_NewStringObj(interp, value_buf, -1));
4746 Jim_DecrRefCount(interp, result_list);
4750 Jim_SetResult(interp, result_list);
4751 Jim_DecrRefCount(interp, result_list);
4762 Jim_Obj *obj_name = Jim_NewStringObj(interp, namebuf, -1);
4768 Jim_IncrRefCount(obj_name);
4769 Jim_Obj *obj_val = Jim_GetVariable(interp, obj_name, JIM_ERRMSG);
4770 Jim_DecrRefCount(interp, obj_name);
4776 int result = Jim_GetWide(interp, obj_val, &wide_val);
4782 int argc, Jim_Obj *
const *argv)
4786 LOG_WARNING(
"DEPRECATED! use 'write_memory' not 'array2mem'");
4794 if (argc < 4 || argc > 5) {
4795 Jim_WrongNumArgs(interp, 0, argv,
"varname width addr nelems [phys]");
4800 const char *varname = Jim_GetString(argv[0],
NULL);
4804 e = Jim_GetLong(interp, argv[1], &l);
4807 const unsigned int width_bits = l;
4809 if (width_bits != 8 &&
4813 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4814 Jim_AppendStrings(interp, Jim_GetResult(interp),
4815 "Invalid width param. Must be one of: 8, 16, 32 or 64.",
NULL);
4818 const unsigned int width = width_bits / 8;
4822 e = Jim_GetWide(interp, argv[2], &wide_addr);
4828 e = Jim_GetLong(interp, argv[3], &l);
4834 bool is_phys =
false;
4837 const char *phys = Jim_GetString(argv[4], &str_len);
4838 if (!strncmp(phys,
"phys", str_len))
4846 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4847 Jim_AppendStrings(interp, Jim_GetResult(interp),
4848 "array2mem: zero width read?",
NULL);
4853 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4854 Jim_AppendStrings(interp, Jim_GetResult(interp),
4855 "array2mem: addr + len - wraps to zero?",
NULL);
4860 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4861 Jim_AppendStrings(interp, Jim_GetResult(interp),
4862 "array2mem: too large memory write request, exceeds 64K items",
NULL);
4873 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4874 sprintf(buf,
"array2mem address: " TARGET_ADDR_FMT " is not aligned for %" PRIu32
" byte reads",
4877 Jim_AppendStrings(interp, Jim_GetResult(interp), buf,
NULL);
4886 const size_t buffersize = 4096;
4887 uint8_t *
buffer = malloc(buffersize);
4896 const unsigned int max_chunk_len = buffersize /
width;
4898 const size_t chunk_len =
MIN(len, max_chunk_len);
4901 for (
size_t i = 0; i < chunk_len; i++, idx++) {
4936 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4937 Jim_AppendStrings(interp, Jim_GetResult(interp),
"array2mem: cannot read memory",
NULL);
4946 Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
4952 Jim_Obj *
const *argv)
4961 if (argc < 4 || argc > 5) {
4962 Jim_WrongNumArgs(interp, 1, argv,
"address width data ['phys']");
4969 e = Jim_GetWide(interp, argv[1], &wide_addr);
4978 e = Jim_GetLong(interp, argv[2], &l);
4983 const unsigned int width_bits = l;
4984 size_t count = Jim_ListLength(interp, argv[3]);
4987 bool is_phys =
false;
4990 const char *phys = Jim_GetString(argv[4],
NULL);
4992 if (strcmp(phys,
"phys")) {
4993 Jim_SetResultFormatted(interp,
"invalid argument '%s', must be 'phys'", phys);
5000 switch (width_bits) {
5007 Jim_SetResultString(interp,
"invalid width, must be 8, 16, 32 or 64", -1);
5011 const unsigned int width = width_bits / 8;
5014 Jim_SetResultString(interp,
"write_memory: addr + len wraps to zero", -1);
5018 if (
count > 65536) {
5019 Jim_SetResultString(interp,
"write_memory: too large memory write request, exceeds 64K elements", -1);
5024 assert(cmd_ctx !=
NULL);
5027 const size_t buffersize = 4096;
5028 uint8_t *
buffer = malloc(buffersize);
5038 const unsigned int max_chunk_len = buffersize /
width;
5039 const size_t chunk_len =
MIN(
count, max_chunk_len);
5041 for (
size_t i = 0; i < chunk_len; i++, j++) {
5042 Jim_Obj *tmp = Jim_ListGetIndex(interp, argv[3], j);
5043 jim_wide element_wide;
5044 Jim_GetWide(interp, tmp, &element_wide);
5046 const uint64_t v = element_wide;
5075 addr, width_bits, chunk_len);
5076 Jim_SetResultString(interp,
"write_memory: failed to write memory", -1);
5098 if (teap->
event == e) {
5099 LOG_DEBUG(
"target(%d): %s (%s) event: %d (%s) action: %s",
5115 retval = Jim_EvalObj(teap->
interp, teap->
body);
5122 if (retval == JIM_RETURN)
5123 retval = teap->
interp->returnCode;
5125 if (retval != JIM_OK) {
5126 Jim_MakeErrorMessage(teap->
interp);
5127 LOG_USER(
"Error executing event %s on target %s:\n%s",
5130 Jim_GetString(Jim_GetResult(teap->
interp),
NULL));
5132 Jim_Eval(teap->
interp,
"error \"\" \"\"");
5139 Jim_Obj *
const *argv)
5144 const char *option = Jim_GetString(argv[1],
NULL);
5146 if (!strcmp(option,
"-force")) {
5151 Jim_SetResultFormatted(interp,
"invalid option '%s'", option);
5157 Jim_WrongNumArgs(interp, 1, argv,
"[-force] list");
5161 const int length = Jim_ListLength(interp, argv[1]);
5163 Jim_Obj *result_dict = Jim_NewDictObj(interp,
NULL, 0);
5169 assert(cmd_ctx !=
NULL);
5172 for (
int i = 0; i <
length; i++) {
5173 Jim_Obj *elem = Jim_ListGetIndex(interp, argv[1], i);
5178 const char *reg_name = Jim_String(elem);
5184 Jim_SetResultFormatted(interp,
"unknown register '%s'", reg_name);
5192 Jim_SetResultFormatted(interp,
"failed to read register '%s'",
5214 Jim_DictAddElement(interp, result_dict, elem,
5215 Jim_NewStringObj(interp, tmp, -1));
5220 Jim_SetResult(interp, result_dict);
5226 Jim_Obj *
const *argv)
5229 Jim_WrongNumArgs(interp, 1, argv,
"dict");
5234 #if JIM_VERSION >= 80
5235 Jim_Obj **dict = Jim_DictPairs(interp, argv[1], &tmp);
5241 int ret = Jim_DictPairs(interp, argv[1], &dict, &tmp);
5247 const unsigned int length = tmp;
5252 for (
unsigned int i = 0; i <
length; i += 2) {
5253 const char *reg_name = Jim_String(dict[i]);
5254 const char *reg_value = Jim_String(dict[i + 1]);
5259 Jim_SetResultFormatted(interp,
"unknown register '%s'", reg_name);
5275 Jim_SetResultFormatted(interp,
"failed to set '%s' to register '%s'",
5276 reg_value, reg_name);
5326 { .name =
"-rtos", .value =
TCFG_RTOS },
5330 { .name =
NULL, .value = -1 }
5341 while (goi->
argc > 0) {
5342 Jim_SetEmptyResult(goi->
interp);
5368 Jim_SetResultFormatted(goi->
interp,
5369 "not settable: %s", n->
name);
5373 if (goi->
argc != 0) {
5374 Jim_WrongNumArgs(goi->
interp,
5380 Jim_SetResultString(goi->
interp,
5385 if (goi->
argc == 0) {
5386 Jim_WrongNumArgs(goi->
interp, goi->
argc, goi->
argv,
"-event ?event-name? ...");
5397 if (goi->
argc != 1) {
5398 Jim_WrongNumArgs(goi->
interp, goi->
argc, goi->
argv,
"-event ?event-name? ?EVENT-BODY?");
5402 if (goi->
argc != 0) {
5403 Jim_WrongNumArgs(goi->
interp, goi->
argc, goi->
argv,
"-event ?event-name?");
5422 LOG_INFO(
"DEPRECATED target event %s; use TPIU events {pre,post}-{enable,disable}", n->
name);
5425 bool replace =
true;
5428 teap = calloc(1,
sizeof(*teap));
5436 teap->
body = Jim_DuplicateObj(goi->
interp, o);
5447 Jim_IncrRefCount(teap->
body);
5454 Jim_SetEmptyResult(goi->
interp);
5458 Jim_SetEmptyResult(goi->
interp);
5547 Jim_SetResultString(goi->
interp, n->
name, -1);
5571 Jim_SetResultString(goi->
interp,
5572 "target requires -dap parameter instead of -chain-position!", -1);
5610 if (result != JIM_OK)
5626 Jim_SetResultString(goi->
interp,
"-gdb-port must be configured before 'init'", -1);
5648 Jim_SetResultString(goi->
interp,
"-gdb-max-connections must be configured before 'init'", -1);
5679 "missing: -option ...");
5689 int argc, Jim_Obj *
const *argv)
5698 int argc, Jim_Obj *
const *argv)
5708 Jim_SetResultFormatted(interp,
"[TAP is disabled]");
5714 bool allow_defer =
false;
5719 const char *cmd_name = Jim_GetString(
argv[0],
NULL);
5720 Jim_SetResultFormatted(goi.
interp,
5721 "usage: %s ['allow-defer']", cmd_name);
5725 strcmp(Jim_GetString(
argv[1],
NULL),
"allow-defer") == 0) {
5742 LOG_INFO(
"Use arp_examine command to examine it manually!");
5780 Jim_WrongNumArgs(interp, 1, argv,
"[no parameters]");
5796 Jim_WrongNumArgs(interp, 1, argv,
"[no parameters]");
5820 if (goi.
argc != 2) {
5822 "([tT]|[fF]|assert|deassert) BOOL");
5845 Jim_SetResultFormatted(interp,
5846 "No target-specific reset for %s",
5864 return (e ==
ERROR_OK) ? JIM_OK : JIM_ERR;
5870 Jim_WrongNumArgs(interp, 1, argv,
"[no parameters]");
5879 return (e ==
ERROR_OK) ? JIM_OK : JIM_ERR;
5888 if (goi.
argc != 2) {
5889 const char *cmd_name = Jim_GetString(
argv[0],
NULL);
5890 Jim_SetResultFormatted(goi.
interp,
5891 "%s <state_name> <timeout_in_msec>", cmd_name);
5913 Jim_Obj *obj = Jim_NewIntObj(interp, e);
5914 Jim_SetResultFormatted(goi.
interp,
5915 "target: %s wait %s fails (%#s) %s",
5935 "----------------------------------------");
5948 Jim_WrongNumArgs(
interp, 1, argv,
"[no parameters]");
5961 if (goi.
argc != 1) {
5962 const char *cmd_name = Jim_GetString(
argv[0],
NULL);
5963 Jim_SetResultFormatted(goi.
interp,
"%s <eventname>", cmd_name);
5981 .
name =
"configure",
5984 .help =
"configure a new target for use",
5985 .usage =
"[target_attribute ...]",
5991 .help =
"returns the specified target attribute",
5992 .usage =
"target_attribute",
5996 .handler = handle_mw_command,
5998 .help =
"Write 64-bit word(s) to target memory",
5999 .usage =
"address data [count]",
6003 .handler = handle_mw_command,
6005 .help =
"Write 32-bit word(s) to target memory",
6006 .usage =
"address data [count]",
6010 .handler = handle_mw_command,
6012 .help =
"Write 16-bit half-word(s) to target memory",
6013 .usage =
"address data [count]",
6017 .handler = handle_mw_command,
6019 .help =
"Write byte(s) to target memory",
6020 .usage =
"address data [count]",
6024 .handler = handle_md_command,
6026 .help =
"Display target memory as 64-bit words",
6027 .usage =
"address [count]",
6031 .handler = handle_md_command,
6033 .help =
"Display target memory as 32-bit words",
6034 .usage =
"address [count]",
6038 .handler = handle_md_command,
6040 .help =
"Display target memory as 16-bit half-words",
6041 .usage =
"address [count]",
6045 .handler = handle_md_command,
6047 .help =
"Display target memory as 8-bit bytes",
6048 .usage =
"address [count]",
6051 .name =
"array2mem",
6054 .help =
"Writes Tcl array of 8/16/32 bit numbers "
6056 .usage =
"arrayname bitwidth address count",
6059 .name =
"mem2array",
6062 .help =
"Loads Tcl array of 8/16/32 bit numbers "
6063 "from target memory",
6064 .usage =
"arrayname bitwidth address count",
6070 .help =
"Get register values from the target",
6077 .help =
"Set target register values",
6081 .name =
"read_memory",
6084 .help =
"Read Tcl list of 8/16/32/64 bit numbers from target memory",
6085 .usage =
"address width count ['phys']",
6088 .name =
"write_memory",
6091 .help =
"Write Tcl list of 8/16/32/64 bit numbers to target memory",
6092 .usage =
"address width data ['phys']",
6095 .name =
"eventlist",
6096 .handler = handle_target_event_list,
6098 .help =
"displays a table of events defined for this target",
6105 .help =
"displays the current state of this target",
6108 .name =
"arp_examine",
6111 .help =
"used internally for reset processing",
6112 .usage =
"['allow-defer']",
6115 .name =
"was_examined",
6118 .help =
"used internally for reset processing",
6121 .name =
"examine_deferred",
6124 .help =
"used internally for reset processing",
6127 .name =
"arp_halt_gdb",
6130 .help =
"used internally for reset processing to halt GDB",
6136 .help =
"used internally for reset processing",
6139 .name =
"arp_reset",
6142 .help =
"used internally for reset processing",
6148 .help =
"used internally for reset processing",
6151 .name =
"arp_waitstate",
6154 .help =
"used internally for reset processing",
6157 .name =
"invoke-event",
6160 .help =
"invoke handler for specified event",
6161 .usage =
"event_name",
6179 if (goi->
argc < 3) {
6180 Jim_WrongNumArgs(goi->
interp, 1, goi->
argv,
"?name? ?type? ..options...");
6187 cmd = Jim_GetCommand(goi->
interp, new_cmd, JIM_NONE);
6189 cp = Jim_GetString(new_cmd,
NULL);
6190 Jim_SetResultFormatted(goi->
interp,
"Command/target: %s Exists", cp);
6202 LOG_ERROR(
"The selected transport doesn't support this target");
6205 LOG_INFO(
"The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD");
6215 Jim_SetResultFormatted(goi->
interp,
"Unknown target type %s, try one of ", cp);
6218 Jim_AppendStrings(goi->
interp,
6219 Jim_GetResult(goi->
interp),
6223 Jim_AppendStrings(goi->
interp,
6224 Jim_GetResult(goi->
interp),
6302 Jim_SetResultString(goi->
interp,
"-dap ?name? required when creating target", -1);
6307 Jim_SetResultString(goi->
interp,
"-chain-position ?name? required when creating target", -1);
6330 cp = Jim_GetString(new_cmd,
NULL);
6360 LOG_ERROR(
"unable to register '%s' commands", cp);
6377 .help =
"target command group",
6379 .chain = target_subcommands,
6406 Jim_WrongNumArgs(interp, 1, argv,
"Too many parameters");
6421 Jim_WrongNumArgs(interp, 1, argv,
"Too many parameters");
6424 Jim_SetResult(interp, Jim_NewListObj(interp,
NULL, 0));
6426 Jim_ListAppendElement(interp, Jim_GetResult(interp),
6435 Jim_WrongNumArgs(interp, 1, argv,
"Too many parameters");
6438 Jim_SetResult(interp, Jim_NewListObj(interp,
NULL, 0));
6441 Jim_ListAppendElement(interp, Jim_GetResult(interp),
6450 create_target_list_node(Jim_Obj *
const name) {
6452 const char *targetname = Jim_GetString(
name, &len);
6476 LOG_ERROR(
"Different rtos types in members of one smp target!");
6488 static int smp_group = 1;
6507 for (
int i = 1; i < argc; i++) {
6508 struct target_list *
new = create_target_list_node(argv[i]);
6521 struct target *rtos_target;
6523 if (retval == JIM_OK && rtos_target)
6536 "<name> <target_type> [<target_options> ...]");
6546 .handler = handle_target_init_command,
6547 .help =
"initialize targets",
6554 .usage =
"name type '-chain-position' name [options ...]",
6555 .help =
"Creates and selects a new target",
6561 .help =
"Returns the currently selected target",
6567 .help =
"Returns the available target types as "
6568 "a list of strings",
6574 .help =
"Returns the names of all targets as a list of strings",
6580 .usage =
"targetname1 targetname2 ...",
6581 .help =
"gather several target in a smp list"
6611 uint32_t image_size;
6618 &
image, &min_address, &max_address);
6655 uint32_t
length = buf_cnt;
6674 command_print(
CMD,
"error allocating buffer for section (%" PRIu32
" bytes)",
6693 "in %fs (%0.3f KiB/s)", image_size,
6697 "WARNING: image has not been loaded to target!"
6698 "You can issue a 'fast_load' to finish loading.");
6724 (
unsigned int)(
fastload[i].address),
6733 command_print(
CMD,
"Loaded image %f kBytes/s", (
float)(
size/1024.0)/((
float)(after-ms)/1000.0));
6741 .handler = handle_targets_command,
6743 .help =
"change current default target (one parameter) "
6744 "or prints table of all targets (no parameters)",
6745 .usage =
"[target]",
6750 .help =
"configure target",
6801 for (
int i = 0; i <
size; i++)
6823 size_t num_bytes = test_size + 4;
6832 uint8_t *test_pattern = malloc(num_bytes);
6834 for (
size_t i = 0; i < num_bytes; i++)
6835 test_pattern[i] = rand();
6843 for (
int host_offset = 0; host_offset <= 1; host_offset++) {
6847 size_t host_bufsiz = (
count + 2) *
size + host_offset;
6848 uint8_t *read_ref = malloc(host_bufsiz);
6849 uint8_t *read_buf = malloc(host_bufsiz);
6851 for (
size_t i = 0; i < host_bufsiz; i++) {
6852 read_ref[i] = rand();
6853 read_buf[i] = read_ref[i];
6856 "Test read %" PRIu32
" x %d @ %d to %saligned buffer: ",
count,
6863 read_buf +
size + host_offset);
6879 int result = memcmp(read_ref, read_buf, host_bufsiz);
6902 num_bytes = test_size + 4 + 4 + 4;
6910 test_pattern = malloc(num_bytes);
6912 for (
size_t i = 0; i < num_bytes; i++)
6913 test_pattern[i] = rand();
6915 for (
int host_offset = 0; host_offset <= 1; host_offset++) {
6919 size_t host_bufsiz =
count *
size + host_offset;
6920 uint8_t *read_ref = malloc(num_bytes);
6921 uint8_t *read_buf = malloc(num_bytes);
6922 uint8_t *write_buf = malloc(host_bufsiz);
6924 for (
size_t i = 0; i < host_bufsiz; i++)
6925 write_buf[i] = rand();
6927 "Test write %" PRIu32
" x %d @ %d from %saligned buffer: ",
count,
6937 memcpy(read_ref, test_pattern, num_bytes);
6944 write_buf + host_offset);
6964 int result = memcmp(read_ref, read_buf, num_bytes);
6989 .
name =
"fast_load_image",
6990 .handler = handle_fast_load_image_command,
6992 .help =
"Load image into server memory for later use by "
6993 "fast_load; primarily for profiling",
6994 .usage =
"filename address ['bin'|'ihex'|'elf'|'s19'] "
6995 "[min_address [max_length]]",
6998 .name =
"fast_load",
6999 .handler = handle_fast_load_command,
7001 .help =
"loads active fast load image to current target "
7002 "- mainly for profiling purposes",
7007 .handler = handle_profile_command,
7009 .usage =
"seconds filename [start end]",
7010 .help =
"profiling samples the CPU PC",
7014 .name =
"virt2phys",
7015 .handler = handle_virt2phys_command,
7017 .help =
"translate a virtual address into a physical address",
7018 .usage =
"virtual_address",
7022 .handler = handle_reg_command,
7024 .help =
"display (reread from target with \"force\") or set a register; "
7025 "with no arguments, displays all registers and their values",
7026 .usage =
"[(register_number|register_name) [(value|'force')]]",
7030 .handler = handle_poll_command,
7032 .help =
"poll target state; or reconfigure background polling",
7033 .usage =
"['on'|'off']",
7036 .name =
"wait_halt",
7037 .handler = handle_wait_halt_command,
7039 .help =
"wait up to the specified number of milliseconds "
7040 "(default 5000) for a previously requested halt",
7041 .usage =
"[milliseconds]",
7045 .handler = handle_halt_command,
7047 .help =
"request target to halt, then wait up to the specified "
7048 "number of milliseconds (default 5000) for it to complete",
7049 .usage =
"[milliseconds]",
7053 .handler = handle_resume_command,
7055 .help =
"resume target execution from current PC or address",
7056 .usage =
"[address]",
7060 .handler = handle_reset_command,
7062 .usage =
"[run|halt|init]",
7063 .help =
"Reset all targets into the specified mode. "
7064 "Default reset mode is run, if not given.",
7067 .name =
"soft_reset_halt",
7068 .handler = handle_soft_reset_halt_command,
7071 .help =
"halt the target and do a soft reset",
7075 .handler = handle_step_command,
7077 .help =
"step one instruction from current PC or address",
7078 .usage =
"[address]",
7082 .handler = handle_md_command,
7084 .help =
"display memory double-words",
7085 .usage =
"['phys'] address [count]",
7089 .handler = handle_md_command,
7091 .help =
"display memory words",
7092 .usage =
"['phys'] address [count]",
7096 .handler = handle_md_command,
7098 .help =
"display memory half-words",
7099 .usage =
"['phys'] address [count]",
7103 .handler = handle_md_command,
7105 .help =
"display memory bytes",
7106 .usage =
"['phys'] address [count]",
7110 .handler = handle_mw_command,
7112 .help =
"write memory double-word",
7113 .usage =
"['phys'] address value [count]",
7117 .handler = handle_mw_command,
7119 .help =
"write memory word",
7120 .usage =
"['phys'] address value [count]",
7124 .handler = handle_mw_command,
7126 .help =
"write memory half-word",
7127 .usage =
"['phys'] address value [count]",
7131 .handler = handle_mw_command,
7133 .help =
"write memory byte",
7134 .usage =
"['phys'] address value [count]",
7138 .handler = handle_bp_command,
7140 .help =
"list or set hardware or software breakpoint",
7141 .usage =
"[<address> [<asid>] <length> ['hw'|'hw_ctx']]",
7145 .handler = handle_rbp_command,
7147 .help =
"remove breakpoint",
7148 .usage =
"'all' | address",
7152 .handler = handle_wp_command,
7154 .help =
"list (no params) or create watchpoints",
7155 .usage =
"[address length [('r'|'w'|'a') value [mask]]]",
7159 .handler = handle_rwp_command,
7161 .help =
"remove watchpoint",
7165 .name =
"load_image",
7166 .handler = handle_load_image_command,
7168 .usage =
"filename address ['bin'|'ihex'|'elf'|'s19'] "
7169 "[min_address] [max_length]",
7172 .name =
"dump_image",
7173 .handler = handle_dump_image_command,
7175 .usage =
"filename address size",
7178 .name =
"verify_image_checksum",
7179 .handler = handle_verify_image_checksum_command,
7181 .usage =
"filename [offset [type]]",
7184 .name =
"verify_image",
7185 .handler = handle_verify_image_command,
7187 .usage =
"filename [offset [type]]",
7190 .name =
"test_image",
7191 .handler = handle_test_image_command,
7193 .usage =
"filename [offset [type]]",
7199 .help =
"Get register values from the target",
7206 .help =
"Set target register values",
7210 .name =
"read_memory",
7213 .help =
"Read Tcl list of 8/16/32/64 bit numbers from target memory",
7214 .usage =
"address width count ['phys']",
7217 .name =
"write_memory",
7220 .help =
"Write Tcl list of 8/16/32/64 bit numbers to target memory",
7221 .usage =
"address width data ['phys']",
7224 .name =
"reset_nag",
7225 .handler = handle_target_reset_nag,
7227 .help =
"Nag after each reset about options that could have been "
7228 "enabled to improve performance.",
7229 .usage =
"['enable'|'disable']",
7233 .handler = handle_ps_command,
7235 .help =
"list all tasks",
7239 .name =
"test_mem_access",
7240 .handler = handle_test_mem_access_command,
7242 .help =
"Test the target's memory access functions",
char * buf_to_hex_str(const void *_buf, unsigned buf_len)
int str_to_buf(const char *str, unsigned str_len, void *_buf, unsigned buf_len, unsigned radix)
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.
void breakpoint_remove_all(struct target *target)
int hybrid_breakpoint_add(struct target *target, target_addr_t address, uint32_t asid, uint32_t length, enum breakpoint_type type)
int context_breakpoint_add(struct target *target, uint32_t asid, uint32_t length, enum breakpoint_type type)
void watchpoint_remove(struct target *target, target_addr_t address)
void breakpoint_remove(struct target *target, target_addr_t address)
int breakpoint_add(struct target *target, target_addr_t address, uint32_t length, enum breakpoint_type type)
int watchpoint_add(struct target *target, target_addr_t address, uint32_t length, enum watchpoint_rw rw, uint32_t value, uint32_t mask)
struct command_context * current_command_context(Jim_Interp *interp)
void command_print_sameline(struct command_invocation *cmd, const char *format,...)
void command_print(struct command_invocation *cmd, const char *format,...)
int command_run_line(struct command_context *context, char *line)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
#define CMD_NAME
Use this macro to access the name of the command being handled, rather than accessing the variable di...
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define COMMAND_PARSE_ADDRESS(in, out)
#define COMMAND_PARSE_ON_OFF(in, out)
parses an on/off command argument
#define ERROR_COMMAND_SYNTAX_ERROR
static int register_commands_override_target(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds, struct target *target)
Register one or more commands, as register_commands(), plus specify that command should override the ...
#define ERROR_COMMAND_CLOSE_CONNECTION
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#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...
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
static struct command * jim_to_command(Jim_Interp *interp)
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
#define ERROR_COMMAND_ARGUMENT_INVALID
static int register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds)
Register one or more commands in the specified context, as children of parent (or top-level commends,...
static struct esp_usb_jtag * priv
#define ERROR_FLASH_OPERATION_FAILED
int fileio_write(struct fileio *fileio, size_t size, const void *buffer, size_t *size_written)
int fileio_close(struct fileio *fileio)
int fileio_size(struct fileio *fileio, size_t *size)
FIX!!!!
int fileio_open(struct fileio **fileio, const char *url, enum fileio_access access_type, enum fileio_type type)
void image_close(struct image *image)
int image_read_section(struct image *image, int section, target_addr_t offset, uint32_t size, uint8_t *buffer, size_t *size_read)
int image_calculate_checksum(const uint8_t *buffer, uint32_t nbytes, uint32_t *checksum)
int image_open(struct image *image, const char *url, const char *type_string)
int jim_getopt_wide(struct jim_getopt_info *goi, jim_wide *puthere)
Remove argv[0] as wide.
int jim_getopt_setup(struct jim_getopt_info *p, Jim_Interp *interp, int argc, Jim_Obj *const *argv)
GetOpt - how to.
struct jim_nvp * jim_nvp_name2value_simple(const struct jim_nvp *p, const char *name)
int jim_getopt_string(struct jim_getopt_info *goi, const char **puthere, int *len)
Remove argv[0] as string.
int jim_getopt_nvp(struct jim_getopt_info *goi, const struct jim_nvp *nvp, struct jim_nvp **puthere)
Remove argv[0] as NVP.
void jim_getopt_nvp_unknown(struct jim_getopt_info *goi, const struct jim_nvp *nvptable, int hadprefix)
Create an appropriate error message for an NVP.
int jim_getopt_obj(struct jim_getopt_info *goi, Jim_Obj **puthere)
Remove argv[0] from the list.
struct jim_nvp * jim_nvp_value2name_simple(const struct jim_nvp *p, int value)
int jtag_unregister_event_callback(jtag_event_handler_t callback, void *priv)
void jtag_poll_unmask(bool saved)
Restore saved mask for polling.
void jtag_poll_set_enabled(bool value)
Assign flag reporting whether JTAG polling is disallowed.
int jtag_srst_asserted(int *srst_asserted)
bool is_jtag_poll_safe(void)
Return true if it's safe for a background polling task to access the JTAG scan chain.
int jtag_power_dropout(int *dropout)
int jtag_register_event_callback(jtag_event_handler_t callback, void *priv)
bool jtag_poll_get_enabled(void)
Return flag reporting whether JTAG polling is disallowed.
bool jtag_poll_mask(void)
Mask (disable) polling and return the current mask status that should be feed to jtag_poll_unmask() t...
The JTAG interface can be implemented with a software or hardware fifo.
struct jtag_tap * jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *obj)
static void list_add(struct list_head *new, struct list_head *head)
list_add - add a new entry
static void list_add_tail(struct list_head *new, struct list_head *head)
list_add_tail - add a new entry
#define list_for_each_entry(pos, head, member)
list_for_each_entry - iterate over list of given type
static void list_del(struct list_head *entry)
list_del - deletes entry from list.
#define list_for_each_entry_safe(pos, n, head, member)
list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
static void INIT_LIST_HEAD(struct list_head *list)
INIT_LIST_HEAD - Initialize a list_head structure.
void alive_sleep(uint64_t ms)
char * alloc_printf(const char *format,...)
#define LOG_TARGET_INFO(target, fmt_str,...)
#define LOG_USER(expr ...)
#define ERROR_NOT_IMPLEMENTED
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
Upper level NOR flash interfaces.
static uint32_t lh(unsigned int rd, unsigned int base, uint16_t offset) __attribute__((unused))
struct reg * register_get_by_name(struct reg_cache *first, const char *name, bool search_all)
int gettimeofday(struct timeval *tv, struct timezone *tz)
void rtos_destroy(struct target *target)
int rtos_smp_init(struct target *target)
int rtos_create(struct jim_getopt_info *goi, struct target *target)
size_t size
Size of the control block search area.
#define CONNECTION_LIMIT_UNLIMITED
#define foreach_smp_target(pos, head)
enum breakpoint_type type
struct target * current_target_override
struct target * current_target
When run_command is called, a new instance will be created on the stack, filled with the proper value...
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
const char * usage
a string listing the options and arguments, required or optional
unsigned int num_sections
struct imagesection * sections
target_addr_t base_address
A TCL -ish GetOpt like code.
Name Value Pairs, aka: NVP.
bool enabled
Is this TAP currently enabled?
int(* get)(struct reg *reg)
int(* set)(struct reg *reg, uint8_t *buf)
const struct reg_arch_type * type
char *(* ps_command)(struct target *target)
const struct rtos_type * type
char * basedir
Base directory for semihosting I/O operations.
struct target_event_action * next
int(* callback)(struct target *target, enum target_event event, void *priv)
struct target_event_callback * next
int(* callback)(struct target *target, enum target_reset_mode reset_mode, void *priv)
int(* callback)(void *priv)
struct target_timer_callback * next
enum target_timer_type type
int(* callback)(struct target *target, size_t len, uint8_t *data, void *priv)
This holds methods shared between all instances of a given target type.
int(* add_context_breakpoint)(struct target *target, struct breakpoint *breakpoint)
int(* add_breakpoint)(struct target *target, struct breakpoint *breakpoint)
int(* write_memory)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Target memory write callback.
int(* hit_watchpoint)(struct target *target, struct watchpoint **hit_watchpoint)
const char * name
Name of this type of target.
int(* deassert_reset)(struct target *target)
The implementation is responsible for polling the target such that target->state reflects the state c...
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_create)(struct target *target, Jim_Interp *interp)
unsigned(* address_bits)(struct target *target)
void(* deinit_target)(struct target *target)
Free all the resources allocated by the target.
int(* halt)(struct target *target)
int(* check_reset)(struct target *target)
int(* gdb_fileio_end)(struct target *target, int retcode, int fileio_errno, bool ctrl_c)
int(* blank_check_memory)(struct target *target, struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value)
int(* assert_reset)(struct target *target)
int(* resume)(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
const struct command_registration * commands
int(* profiling)(struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
int(* soft_reset_halt)(struct target *target)
int(* arch_state)(struct target *target)
int(* read_memory)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Target memory read callback.
int(* get_gdb_fileio_info)(struct target *target, struct gdb_fileio_info *fileio_info)
unsigned int(* data_bits)(struct target *target)
int(* target_jim_configure)(struct target *target, struct jim_getopt_info *goi)
int(* read_phys_memory)(struct target *target, target_addr_t phys_address, uint32_t size, uint32_t count, uint8_t *buffer)
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.
int(* mmu)(struct target *target, int *enabled)
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)
int(* read_buffer)(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
int(* step)(struct target *target, int current, target_addr_t address, int handle_breakpoints)
const char *(* get_gdb_arch)(struct target *target)
Target architecture for GDB.
int(* add_watchpoint)(struct target *target, struct watchpoint *watchpoint)
int(* write_buffer)(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int(* poll)(struct target *target)
int(* add_hybrid_breakpoint)(struct target *target, struct breakpoint *breakpoint)
int(* examine)(struct target *target)
This method is used to perform target setup that requires JTAG access.
int(* write_phys_memory)(struct target *target, target_addr_t phys_address, uint32_t size, uint32_t count, const uint8_t *buffer)
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(* remove_breakpoint)(struct target *target, struct breakpoint *breakpoint)
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)
int(* virt2phys)(struct target *target, target_addr_t address, target_addr_t *physical)
int(* checksum_memory)(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
int(* remove_watchpoint)(struct target *target, struct watchpoint *watchpoint)
struct semihosting * semihosting
target_addr_t working_area
target_addr_t working_area_virt
uint32_t working_area_size
struct trace * trace_info
enum target_debug_reason debug_reason
enum target_endianness endianness
struct reg_cache * reg_cache
struct list_head * smp_targets
struct target_event_action * event_action
struct breakpoint * breakpoints
struct working_area * working_areas
struct gdb_fileio_info * fileio_info
struct debug_msg_receiver * dbgmsg
struct target_type * type
struct backoff_timer backoff
target_addr_t working_area_phys
struct watchpoint * watchpoints
bool working_area_phys_spec
bool running_alg
true if the target is currently running a downloaded "algorithm" instead of arbitrary user code.
bool working_area_virt_spec
bool examined
Indicates whether this target has been examined.
uint32_t backup_working_area
bool defer_examine
Should we defer examine to later.
Wrapper for transport lifecycle operations.
int(* override_target)(const char **targetname)
Optional.
struct working_area * next
struct working_area ** user
COMMAND_HANDLER(handle_target_init_command)
static bool target_reset_nag
static int target_array2mem(Jim_Interp *interp, struct target *target, int argc, Jim_Obj *const *argv)
void target_buffer_get_u16_array(struct target *target, const uint8_t *buffer, uint32_t count, uint16_t *dstbuf)
void target_buffer_set_u24(struct target *target, uint8_t *buffer, uint32_t value)
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.
static int run_srst_deasserted
int target_add_watchpoint(struct target *target, struct watchpoint *watchpoint)
Add the watchpoint for target.
static int target_call_timer_callback(struct target_timer_callback *cb, int64_t *now)
struct target * all_targets
static int target_get_gdb_fileio_info_default(struct target *target, struct gdb_fileio_info *fileio_info)
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 esp32s3_target
Holds methods for Xtensa targets.
static int jim_target_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int target_write_phys_u32(struct target *target, target_addr_t address, uint32_t value)
uint64_t target_buffer_get_u64(struct target *target, const uint8_t *buffer)
int target_call_event_callbacks(struct target *target, enum target_event event)
struct target * get_target(const char *id)
void target_free_all_working_areas(struct target *target)
const char * target_state_name(struct target *t)
Return the name of this targets current state.
static int jim_target_halt(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int target_unregister_reset_callback(int(*callback)(struct target *target, enum target_reset_mode reset_mode, void *priv), void *priv)
int target_write_phys_u64(struct target *target, target_addr_t address, uint64_t value)
static int jim_target_current_state(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int target_jim_write_memory(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int target_write_buffer_default(struct target *target, target_addr_t address, uint32_t count, const uint8_t *buffer)
int target_unregister_event_callback(int(*callback)(struct target *target, enum target_event event, void *priv), void *priv)
static int jim_target_examine_deferred(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static void write_long(FILE *f, int l, struct target *target)
int target_read_phys_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
static void binprint(struct command_invocation *cmd, const char *text, const uint8_t *buf, int size)
struct target_type arm966e_target
Holds methods for ARM966 targets.
static int new_u64_array_element(Jim_Interp *interp, const char *varname, int idx, uint64_t val)
struct target_type avr32_ap7k_target
struct target_type testee_target
int target_register_event_callback(int(*callback)(struct target *target, enum target_event event, void *priv), void *priv)
static const struct command_registration target_command_handlers[]
struct target_type esirisc_target
int target_write_phys_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
static int run_power_restore
int target_halt(struct target *target)
static struct target_timer_callback * target_timer_callbacks
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.
static int target_mem2array(Jim_Interp *interp, struct target *target, int argc, Jim_Obj *const *argv)
const char * target_get_gdb_arch(struct target *target)
Obtain the architecture for GDB.
int target_arch_state(struct target *target)
void target_buffer_set_u16(struct target *target, uint8_t *buffer, uint16_t value)
static int target_free_working_area_restore(struct target *target, struct working_area *area, int restore)
static int jim_target_tap_disabled(Jim_Interp *interp)
static int jim_target_types(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int target_remove_breakpoint(struct target *target, struct breakpoint *breakpoint)
Remove the breakpoint for target.
static int target_profiling(struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
void target_buffer_set_u32(struct target *target, uint8_t *buffer, uint32_t value)
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 target_register_commands(struct command_context *cmd_ctx)
static int target_read_buffer_default(struct target *target, target_addr_t address, uint32_t count, uint8_t *buffer)
int target_checksum_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t *crc)
static void target_merge_working_areas(struct target *target)
static int handle_bp_command_list(struct command_invocation *cmd)
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
static const struct jim_nvp nvp_target_debug_reason[]
int target_add_hybrid_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add the ContextID & IVA breakpoint for target.
static int default_examine(struct target *target)
struct target_type cortexm_target
int target_write_u8(struct target *target, target_addr_t address, uint8_t value)
int target_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add the breakpoint for target.
target_addr_t target_address_max(struct target *target)
Return the highest accessible address for this target.
int target_write_u16(struct target *target, target_addr_t address, uint16_t value)
struct target_type arm926ejs_target
Holds methods for ARM926 targets.
int target_unregister_timer_callback(int(*callback)(void *priv), void *priv)
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 int target_jim_get_reg(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
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, target_addr_t exit_point, int timeout_ms, void *arch_info)
Waits for an algorithm started with target_start_algorithm() to complete.
static struct jim_nvp nvp_config_opts[]
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
static int jim_target_configure(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int target_unregister_trace_callback(int(*callback)(struct target *target, size_t len, uint8_t *data, void *priv), void *priv)
int target_call_timer_callbacks_now()
Invoke this to ensure that e.g.
int target_read_u8(struct target *target, target_addr_t address, uint8_t *value)
static void write_string(FILE *f, char *s)
int target_blank_check_memory(struct target *target, struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value)
static int jim_target_current(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int target_jim_read_memory(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
bool target_supports_gdb_connection(struct target *target)
Check if target allows GDB connections.
struct target_type mem_ap_target
static void target_buffer_set_u8(struct target *target, uint8_t *buffer, uint8_t value)
struct target_type dragonite_target
static struct target_list * __attribute__((warn_unused_result))
struct target * get_target_by_num(int num)
struct target_type stm8_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 new_target_number(void)
struct target_type arcv2_target
static const struct command_registration target_subcommand_handlers[]
static const struct jim_nvp nvp_reset_modes[]
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.
unsigned target_address_bits(struct target *target)
Return the number of address bits this target supports.
static int jtag_enable_callback(enum jtag_event event, 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)
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.
struct target_type cortexr4_target
int target_call_timer_callbacks()
struct target_type quark_d20xx_target
struct target_type mips_mips64_target
int target_write_u64(struct target *target, target_addr_t address, uint64_t value)
static int jim_target_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static struct target_event_callback * target_event_callbacks
struct target_type feroceon_target
static COMMAND_HELPER(parse_load_image_command, struct image *image, target_addr_t *min_address, target_addr_t *max_address)
struct target * get_current_target_or_null(struct command_context *cmd_ctx)
struct target_type arm9tdmi_target
Holds methods for ARM9TDMI targets.
static void target_split_working_area(struct working_area *area, uint32_t size)
struct target_type nds32_v3m_target
Holds methods for NDS32 V3m targets.
static int target_init(struct command_context *cmd_ctx)
int target_hit_watchpoint(struct target *target, struct watchpoint **hit_watchpoint)
Find out the just hit watchpoint for target.
static const struct jim_nvp nvp_target_event[]
int target_call_reset_callbacks(struct target *target, enum target_reset_mode reset_mode)
uint32_t target_get_working_area_avail(struct target *target)
@ TCFG_GDB_MAX_CONNECTIONS
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
static int jim_target_wait_state(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static const struct command_registration target_instance_command_handlers[]
struct target_type or1k_target
bool get_target_reset_nag(void)
int target_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
Step the target.
unsigned int target_data_bits(struct target *target)
Return the number of data bits this target supports.
static int find_target(struct command_invocation *cmd, const char *name)
struct target_type quark_x10xx_target
static int jim_target_halt_gdb(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
struct target_type esp32s2_target
struct target_type riscv_target
int target_remove_watchpoint(struct target *target, struct watchpoint *watchpoint)
Remove the watchpoint for target.
const char * target_event_name(enum target_event event)
Return the name of a target event enumeration value.
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
int target_examine_one(struct target *target)
Examine the specified target, letting it perform any Initialisation that requires JTAG access.
int(* target_write_fn)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
static int target_create(struct jim_getopt_info *goi)
static void print_wa_layout(struct target *target)
#define DEFAULT_HALT_TIMEOUT
int target_poll(struct target *target)
static int target_call_timer_callbacks_check_time(int checktime)
static int sense_handler(void)
static int target_timer_callback_periodic_restart(struct target_timer_callback *cb, int64_t *now)
int target_free_working_area(struct target *target, struct working_area *area)
Free a working area.
struct target_type esp32_target
Holds methods for Xtensa targets.
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, target_addr_t entry_point, target_addr_t exit_point, int timeout_ms, void *arch_info)
Downloads a target-specific native code algorithm to the target, and executes it.
int target_alloc_working_area_try(struct target *target, uint32_t size, struct working_area **area)
static int target_jim_set_reg(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
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 target_read_u16(struct target *target, target_addr_t address, uint16_t *value)
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...
static int get_u64_array_element(Jim_Interp *interp, const char *varname, size_t idx, uint64_t *val)
void target_buffer_set_u64(struct target *target, uint8_t *buffer, uint64_t value)
struct target_type xtensa_chip_target
Methods for generic example of Xtensa-based chip-level targets.
static const int polling_interval
void target_buffer_set_u64_array(struct target *target, uint8_t *buffer, uint32_t count, const uint64_t *srcbuf)
static void target_reset_examined(struct target *target)
Reset the examined flag for the given target.
int target_add_context_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add the ContextID breakpoint for target.
static int target_init_one(struct command_context *cmd_ctx, struct target *target)
static int run_power_dropout
static int jim_target_examine(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
struct target_type aarch64_target
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
uint16_t target_buffer_get_u16(struct target *target, const uint8_t *buffer)
static int jim_target_was_examined(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
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 const struct command_registration target_exec_command_handlers[]
void target_buffer_get_u64_array(struct target *target, const uint8_t *buffer, uint32_t count, uint64_t *dstbuf)
static int default_check_reset(struct target *target)
static int jim_target_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
struct target_type arm946e_target
Holds methods for ARM946 targets.
void target_buffer_set_u16_array(struct target *target, uint8_t *buffer, uint32_t count, const uint16_t *srcbuf)
static struct fast_load * fastload
struct target_type arm11_target
Holds methods for ARM11xx targets.
int target_register_reset_callback(int(*callback)(struct target *target, enum target_reset_mode reset_mode, void *priv), void *priv)
struct target_type arm7tdmi_target
Holds methods for ARM7TDMI targets.
uint32_t target_buffer_get_u24(struct target *target, const uint8_t *buffer)
struct target_type arm920t_target
Holds methods for ARM920 targets.
static int run_srst_asserted
void target_buffer_get_u32_array(struct target *target, const uint8_t *buffer, uint32_t count, uint32_t *dstbuf)
static int get_target_with_common_rtos_type(struct list_head *lh, struct target **result)
static const struct jim_nvp nvp_target_endian[]
int64_t target_timer_next_event(void)
Returns when the next registered event will take place.
int target_write_phys_u16(struct target *target, target_addr_t address, uint16_t value)
static void free_fastload(void)
struct target_type arm720t_target
Holds methods for ARM720 targets.
static int handle_bp_command_set(struct command_invocation *cmd, target_addr_t addr, uint32_t asid, uint32_t length, int hw)
static int handle_target(void *priv)
struct target_type avr_target
static int target_restore_working_area(struct target *target, struct working_area *area)
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_reset(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
struct target_type mips_m4k_target
static int target_gdb_fileio_end_default(struct target *target, int retcode, int fileio_errno, bool ctrl_c)
struct target_type hla_target
static void target_destroy(struct target *target)
static int target_configure(struct jim_getopt_info *goi, struct target *target)
static LIST_HEAD(target_reset_callback_list)
int target_register_trace_callback(int(*callback)(struct target *target, size_t len, uint8_t *data, void *priv), void *priv)
struct target * get_current_target(struct command_context *cmd_ctx)
void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, const uint32_t *srcbuf)
static void write_gmon(uint32_t *samples, uint32_t sample_num, const char *filename, bool with_range, uint32_t start_address, uint32_t end_address, struct target *target, uint32_t duration_ms)
static int identity_virt2phys(struct target *target, target_addr_t virtual, target_addr_t *physical)
struct target_type dsp5680xx_target
Holds methods for dsp5680xx targets.
static int target_register_user_commands(struct command_context *cmd_ctx)
static void append_to_list_all_targets(struct target *target)
void target_handle_event(struct target *target, enum target_event e)
struct target_type dsp563xx_target
Holds methods for DSP563XX targets.
uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer)
static int target_soft_reset_halt(struct target *target)
struct target_type fa526_target
Holds methods for FA526 targets.
const char * debug_reason_name(struct target *t)
static int jim_target_invoke_event(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int no_mmu(struct target *target, int *enabled)
int target_call_trace_callbacks(struct target *target, size_t len, uint8_t *data)
static int target_process_reset(struct command_invocation *cmd, enum target_reset_mode reset_mode)
static const char * target_strerror_safe(int err)
struct target_type nds32_v3_target
Holds methods for Andes1337 targets.
static int64_t target_timer_next_event_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, target_addr_t entry_point, target_addr_t exit_point, void *arch_info)
Executes a target-specific native code algorithm and leaves it running.
static void write_data(FILE *f, const void *data, size_t len)
const char * target_type_name(struct target *target)
Get the target type name.
static const struct jim_nvp nvp_error_target[]
static int jim_target_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
void target_quit(void)
Free all the resources allocated by targets and the target layer.
int target_write_phys_u8(struct target *target, target_addr_t address, uint8_t value)
static struct target_type * target_types[]
struct target_type ls1_sap_target
int target_read_u64(struct target *target, target_addr_t address, uint64_t *value)
const char * target_reset_mode_name(enum target_reset_mode reset_mode)
Return the name of a target reset reason enumeration value.
struct target_type cortexa_target
static void target_free_all_working_areas_restore(struct target *target, int restore)
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...
struct target_type xscale_target
static const struct jim_nvp nvp_target_state[]
struct target_type nds32_v2_target
Holds methods for V2 targets.
static int jim_target_poll(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
int target_wait_state(struct target *target, enum target_state state, int ms)
#define ERROR_TARGET_NOT_HALTED
#define ERROR_TARGET_INIT_FAILED
#define ERROR_TARGET_UNALIGNED_ACCESS
#define ERROR_TARGET_INVALID
@ TARGET_TIMER_TYPE_PERIODIC
@ TARGET_EVENT_DEBUG_RESUMED
@ TARGET_EVENT_EXAMINE_START
@ TARGET_EVENT_RESET_START
@ TARGET_EVENT_SEMIHOSTING_USER_CMD_0X106
@ TARGET_EVENT_GDB_FLASH_WRITE_END
@ TARGET_EVENT_RESET_ASSERT_POST
@ TARGET_EVENT_RESET_DEASSERT_POST
@ TARGET_EVENT_SEMIHOSTING_USER_CMD_0X102
@ TARGET_EVENT_SEMIHOSTING_USER_CMD_0X107
@ TARGET_EVENT_SEMIHOSTING_USER_CMD_0X105
@ TARGET_EVENT_EXAMINE_FAIL
@ TARGET_EVENT_EXAMINE_END
@ TARGET_EVENT_SEMIHOSTING_USER_CMD_0X104
@ TARGET_EVENT_RESET_INIT
@ TARGET_EVENT_RESET_DEASSERT_PRE
@ TARGET_EVENT_GDB_FLASH_ERASE_START
@ TARGET_EVENT_SEMIHOSTING_USER_CMD_0X103
@ TARGET_EVENT_DEBUG_HALTED
@ TARGET_EVENT_RESET_ASSERT_PRE
@ TARGET_EVENT_RESET_ASSERT
@ TARGET_EVENT_GDB_FLASH_WRITE_START
@ TARGET_EVENT_RESUME_START
@ TARGET_EVENT_STEP_START
@ TARGET_EVENT_GDB_ATTACH
@ TARGET_EVENT_SEMIHOSTING_USER_CMD_0X100
@ TARGET_EVENT_SEMIHOSTING_USER_CMD_0X101
@ TARGET_EVENT_RESUME_END
@ TARGET_EVENT_GDB_FLASH_ERASE_END
@ TARGET_EVENT_GDB_DETACH
@ TARGET_EVENT_TRACE_CONFIG
#define ERROR_TARGET_NOT_EXAMINED
#define TARGET_DEFAULT_POLLING_INTERVAL
static const char * target_name(struct target *target)
Returns the instance-specific name of the specified target.
#define ERROR_TARGET_TIMEOUT
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
static void target_set_examined(struct target *target)
Sets the examined flag for the given target.
#define ERROR_TARGET_NOT_RUNNING
static bool target_was_examined(struct target *target)
#define ERROR_TARGET_DATA_ABORT
#define ERROR_TARGET_FAILURE
#define ERROR_TARGET_TRANSLATION_FAULT
int target_request_register_commands(struct command_context *cmd_ctx)
float duration_elapsed(const struct duration *duration)
int timeval_compare(const struct timeval *x, const struct timeval *y)
int timeval_add_time(struct timeval *result, long sec, long usec)
int duration_measure(struct duration *duration)
Update the duration->elapsed field to finish the duration measurement.
int duration_start(struct duration *duration)
Update the duration->start field to start the duration measurement.
float duration_kbps(const struct duration *duration, size_t count)
int trace_register_commands(struct command_context *cmd_ctx)
struct transport * get_current_transport(void)
Returns the transport currently being used by this debug or programming session.
static void h_u32_to_be(uint8_t *buf, uint32_t val)
static uint64_t le_to_h_u64(const uint8_t *buf)
static uint32_t be_to_h_u24(const uint8_t *buf)
static void h_u16_to_be(uint8_t *buf, uint16_t val)
static uint64_t be_to_h_u64(const uint8_t *buf)
static uint16_t le_to_h_u16(const uint8_t *buf)
static uint32_t le_to_h_u24(const uint8_t *buf)
static void h_u32_to_le(uint8_t *buf, uint32_t val)
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
static uint32_t be_to_h_u32(const uint8_t *buf)
static void h_u24_to_le(uint8_t *buf, unsigned int val)
static void h_u24_to_be(uint8_t *buf, unsigned int val)
static uint16_t be_to_h_u16(const uint8_t *buf)
static void h_u16_to_le(uint8_t *buf, uint16_t val)
static uint32_t le_to_h_u32(const uint8_t *buf)
static void h_u64_to_be(uint8_t *buf, uint64_t val)
static void h_u64_to_le(uint8_t *buf, uint64_t val)