target: use unsigned int for timeout_ms
[openocd.git] / src / target / dsp563xx.c
index 21bed899653d839072dc3d05404e21b84b892726..8ea2cb61321d0986ed6d590701542b706cb4867c 100644 (file)
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /***************************************************************************
  *   Copyright (C) 2009-2011 by Mathias Kuester                            *
  *   mkdorg@users.sourceforge.net                                          *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
 /*
  * 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)
@@ -913,7 +902,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;
@@ -1085,9 +1074,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;
@@ -1376,7 +1374,7 @@ static int dsp563xx_run_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,
-       int timeout_ms, void *arch_info)
+       unsigned int timeout_ms, void *arch_info)
 {
        int i;
        int retval = ERROR_OK;
@@ -1402,7 +1400,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);
@@ -1444,7 +1442,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;
@@ -1876,17 +1874,17 @@ static int dsp563xx_remove_watchpoint(struct target *target, struct watchpoint *
        return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
 }
 
-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) {
@@ -1896,8 +1894,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;
@@ -1908,7 +1906,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;
                }
        }
@@ -1972,7 +1970,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);
        }
@@ -2142,7 +2140,7 @@ COMMAND_HANDLER(dsp563xx_mem_command)
                        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], count);
        }
 
-       buffer = calloc(count, sizeof(uint32_t));
+       buffer = calloc(count, 4);
 
        if (read_mem == 1) {
                err = dsp563xx_read_memory(target, mem_type, address, sizeof(uint32_t),

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)