aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/target/dsp563xx.c63
-rw-r--r--src/target/target.c4
-rw-r--r--src/target/target.h5
3 files changed, 8 insertions, 64 deletions
diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c
index d8285e49..ef7a31aa 100644
--- a/src/target/dsp563xx.c
+++ b/src/target/dsp563xx.c
@@ -1875,67 +1875,6 @@ static int dsp563xx_remove_watchpoint(struct target *target, struct watchpoint *
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
-static void handle_md_output(struct command_invocation *cmd,
- struct target *target,
- uint32_t address,
- unsigned size,
- unsigned count,
- const uint8_t *buffer)
-{
- const unsigned line_bytecnt = 32;
- unsigned line_modulo = line_bytecnt / size;
-
- char output[line_bytecnt * 4 + 1];
- unsigned output_len = 0;
-
- const char *value_fmt;
- switch (size) {
- case 4:
- value_fmt = "%8.8x ";
- break;
- case 2:
- value_fmt = "%4.4x ";
- break;
- case 1:
- value_fmt = "%2.2x ";
- break;
- default:
- /* "can't happen", caller checked */
- LOG_ERROR("invalid memory read size: %u", size);
- return;
- }
-
- for (unsigned i = 0; i < count; i++) {
- if (i % line_modulo == 0)
- output_len += snprintf(output + output_len,
- sizeof(output) - output_len,
- "0x%8.8x: ",
- (unsigned) (address + i));
-
- uint32_t value = 0;
- const uint8_t *value_ptr = buffer + i * size;
- switch (size) {
- case 4:
- value = target_buffer_get_u32(target, value_ptr);
- break;
- case 2:
- value = target_buffer_get_u16(target, value_ptr);
- break;
- case 1:
- value = *value_ptr;
- }
- output_len += snprintf(output + output_len,
- sizeof(output) - output_len,
- value_fmt,
- value);
-
- if ((i % line_modulo == line_modulo - 1) || (i == count - 1)) {
- command_print(cmd, "%s", output);
- output_len = 0;
- }
- }
-}
-
static int dsp563xx_add_custom_watchpoint(struct target *target, uint32_t address, uint32_t memType,
enum watchpoint_rw rw, enum watchpoint_condition cond)
{
@@ -2208,7 +2147,7 @@ COMMAND_HANDLER(dsp563xx_mem_command)
err = dsp563xx_read_memory(target, mem_type, address, sizeof(uint32_t),
count, buffer);
if (err == ERROR_OK)
- handle_md_output(CMD, target, address, sizeof(uint32_t), count, buffer);
+ target_handle_md_output(CMD, target, address, sizeof(uint32_t), count, buffer);
} else {
b = buffer;
diff --git a/src/target/target.c b/src/target/target.c
index 0401ff01..1e42c5ee 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -3119,7 +3119,7 @@ COMMAND_HANDLER(handle_step_command)
return target->type->step(target, current_pc, addr, 1);
}
-static void handle_md_output(struct command_invocation *cmd,
+void target_handle_md_output(struct command_invocation *cmd,
struct target *target, target_addr_t address, unsigned size,
unsigned count, const uint8_t *buffer)
{
@@ -3234,7 +3234,7 @@ COMMAND_HANDLER(handle_md_command)
struct target *target = get_current_target(CMD_CTX);
int retval = fn(target, address, size, count, buffer);
if (ERROR_OK == retval)
- handle_md_output(CMD, target, address, size, count, buffer);
+ target_handle_md_output(CMD, target, address, size, count, buffer);
free(buffer);
diff --git a/src/target/target.h b/src/target/target.h
index 65494afd..e944838a 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -36,6 +36,7 @@
struct reg;
struct trace;
struct command_context;
+struct command_invocation;
struct breakpoint;
struct watchpoint;
struct mem_param;
@@ -729,6 +730,10 @@ int target_arch_state(struct target *target);
void target_handle_event(struct target *t, enum target_event e);
+void target_handle_md_output(struct command_invocation *cmd,
+ struct target *target, target_addr_t address, unsigned size,
+ unsigned count, const uint8_t *buffer);
+
#define ERROR_TARGET_INVALID (-300)
#define ERROR_TARGET_INIT_FAILED (-301)
#define ERROR_TARGET_TIMEOUT (-302)