This is an automated email from Gerrit.

Tomas Vanek (van...@fbl.cz) just uploaded a new patch set to Gerrit, which you 
can find at http://openocd.zylin.com/5175

-- gerrit

commit e8ded80afd571c322f8c9d439ad543d94bda3174
Author: Tomas Vanek <van...@fbl.cz>
Date:   Thu Nov 22 19:05:04 2018 +0100

    target: make handle_md_output() global
    
    Remove a copy of handle_md_output() from src/target/dsp563xx.c
    
    Change-Id: Iadd003fd1dcdbc7990d46a58ee2e7c30826ac6af
    Signed-off-by: Tomas Vanek <van...@fbl.cz>

diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c
index d8285e4..ef7a31a 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 ee6ff30..aa3e651 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -3125,7 +3125,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)
 {
@@ -3240,7 +3240,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 65494af..e944838 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)

-- 


_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to