target: use target_event_name()
[openocd.git] / src / target / dsp563xx.c
index d8285e49c8839ec818e94394ccae0df0eb7818b7..0d80ed367525c02fe827085aab464283a297978d 100644 (file)
 /*
  * OBCR Register bit definitions
  */
-#define OBCR_b0_and_b1            ((0x0) << 10)
-#define OBCR_b0_or_b1             ((0x1) << 10)
-#define OBCR_b1_after_b0          ((0x2) << 10)
-#define OBCR_b0_after_b1          ((0x3) << 10)
+#define OBCR_B0_AND_B1            ((0x0) << 10)
+#define OBCR_B0_OR_B1             ((0x1) << 10)
+#define OBCR_B1_AFTER_B0          ((0x2) << 10)
+#define OBCR_B0_AFTER_B1          ((0x3) << 10)
 
 #define OBCR_BP_DISABLED          (0x0)
 #define OBCR_BP_MEM_P             (0x1)
@@ -322,7 +322,7 @@ enum watchpoint_condition {
 #define INSTR_JUMP      0x0AF080
 /* Effective Addressing Mode Encoding */
 #define EAME_R0         0x10
-/* instrcution encoder */
+/* instruction encoder */
 /* movep
  * s - peripheral space X/Y (X=0,Y=1)
  * w - write/read
@@ -475,6 +475,7 @@ static void dsp563xx_build_reg_cache(struct target *target)
                reg_list[i].value = calloc(1, 4);
                reg_list[i].dirty = false;
                reg_list[i].valid = false;
+               reg_list[i].exist = true;
                reg_list[i].type = &dsp563xx_reg_type;
                reg_list[i].arch_info = &arch_info[i];
        }
@@ -912,7 +913,7 @@ static int dsp563xx_init_target(struct command_context *cmd_ctx, struct target *
        dsp563xx_build_reg_cache(target);
        struct dsp563xx_common *dsp563xx = target_to_dsp563xx(target);
 
-       dsp563xx->hardware_breakpoints_cleared = 0;
+       dsp563xx->hardware_breakpoints_cleared = false;
        dsp563xx->hardware_breakpoint[0].used = BPU_NONE;
 
        return ERROR_OK;
@@ -936,7 +937,7 @@ static int dsp563xx_examine(struct target *target)
                if (((chip>>5)&0x1f) == 0)
                        chip += 300;
 
-               LOG_INFO("DSP56%03" PRId32 " device found", chip);
+               LOG_INFO("DSP56%03" PRIu32 " device found", chip);
 
                /* Clear all breakpoints */
                dsp563xx_once_reg_write(target->tap, 1, DSP563XX_ONCE_OBCR, 0);
@@ -1084,9 +1085,18 @@ static int dsp563xx_poll(struct target *target)
 
        if (!dsp563xx->hardware_breakpoints_cleared) {
                err = dsp563xx_once_reg_write(target->tap, 1, DSP563XX_ONCE_OBCR, 0);
+               if (err != ERROR_OK)
+                       return err;
+
                err = dsp563xx_once_reg_write(target->tap, 1, DSP563XX_ONCE_OMLR0, 0);
+               if (err != ERROR_OK)
+                       return err;
+
                err = dsp563xx_once_reg_write(target->tap, 1, DSP563XX_ONCE_OMLR1, 0);
-               dsp563xx->hardware_breakpoints_cleared = 1;
+               if (err != ERROR_OK)
+                       return err;
+
+               dsp563xx->hardware_breakpoints_cleared = true;
        }
 
        return ERROR_OK;
@@ -1358,7 +1368,7 @@ static int dsp563xx_deassert_reset(struct target *target)
                if (target->state == TARGET_HALTED) {
                        /* after a reset the cpu jmp to the
                         * reset vector and need 2 cycles to fill
-                        * the cache (fetch,decode,excecute)
+                        * the cache (fetch,decode,execute)
                         */
                        err = dsp563xx_step_ex(target, 1, 0, 1, 1);
                        if (err != ERROR_OK)
@@ -1401,7 +1411,7 @@ static int dsp563xx_run_algorithm(struct target *target,
 
                struct reg *reg = register_get_by_name(dsp563xx->core_cache,
                                reg_params[i].reg_name,
-                               0);
+                               false);
 
                if (!reg) {
                        LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name);
@@ -1443,7 +1453,7 @@ static int dsp563xx_run_algorithm(struct target *target,
 
                        struct reg *reg = register_get_by_name(dsp563xx->core_cache,
                                        reg_params[i].reg_name,
-                                       0);
+                                       false);
                        if (!reg) {
                                LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name);
                                continue;
@@ -1875,78 +1885,17 @@ 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,
+static int dsp563xx_add_custom_watchpoint(struct target *target, uint32_t address, uint32_t mem_type,
                enum watchpoint_rw rw, enum watchpoint_condition cond)
 {
        int err = ERROR_OK;
        struct dsp563xx_common *dsp563xx = target_to_dsp563xx(target);
 
-       bool wasRunning = false;
+       bool was_running = false;
        /* Only set breakpoint when halted */
        if (target->state != TARGET_HALTED) {
                dsp563xx_halt(target);
-               wasRunning = true;
+               was_running = true;
        }
 
        if (dsp563xx->hardware_breakpoint[0].used) {
@@ -1956,8 +1905,8 @@ static int dsp563xx_add_custom_watchpoint(struct target *target, uint32_t addres
 
        uint32_t obcr_value = 0;
        if      (err == ERROR_OK) {
-               obcr_value |= OBCR_b0_or_b1;
-               switch (memType) {
+               obcr_value |= OBCR_B0_OR_B1;
+               switch (mem_type) {
                        case MEM_X:
                                obcr_value |= OBCR_BP_MEM_X;
                                break;
@@ -1968,7 +1917,7 @@ static int dsp563xx_add_custom_watchpoint(struct target *target, uint32_t addres
                                obcr_value |= OBCR_BP_MEM_P;
                                break;
                        default:
-                               LOG_ERROR("Unknown memType parameter (%" PRIu32 ")", memType);
+                               LOG_ERROR("Unknown mem_type parameter (%" PRIu32 ")", mem_type);
                                err = ERROR_TARGET_INVALID;
                }
        }
@@ -2032,7 +1981,7 @@ static int dsp563xx_add_custom_watchpoint(struct target *target, uint32_t addres
        if (err == ERROR_OK)
                dsp563xx->hardware_breakpoint[0].used = BPU_WATCHPOINT;
 
-       if (err == ERROR_OK && wasRunning) {
+       if (err == ERROR_OK && was_running) {
                /* Resume from current PC */
                err = dsp563xx_resume(target, 1, 0x0, 0, 0);
        }
@@ -2208,7 +2157,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;
@@ -2303,7 +2252,7 @@ static const struct command_registration dsp563xx_command_handlers[] = {
                .handler = dsp563xx_remove_watchpoint_command,
                .mode = COMMAND_EXEC,
                .help = "remove watchpoint custom",
-               .usage = " ",
+               .usage = "",
        },
        COMMAND_REGISTRATION_DONE
 };

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)