target/adi_v5_swd: update cached value on write to DP_SELECT
[openocd.git] / src / target / embeddedice.c
index a7956950823835bc7afce9b9a1bf477706ed661a..61ee8bbd92f0d5e63128043f1eaf23c4604db57d 100644 (file)
@@ -19,9 +19,7 @@
  *   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, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -30,6 +28,7 @@
 
 #include "embeddedice.h"
 #include "register.h"
+#include <helper/time_support.h>
 
 /**
  * @file
@@ -54,9 +53,9 @@ static int embeddedice_set_reg_w_exec(struct reg *reg, uint8_t *buf);
  * From:  ARM9E-S TRM, DDI 0165, table C-4 (and similar, for other cores)
  */
 static const struct {
-       char            *name;
-       unsigned short  addr;
-       unsigned short  width;
+       const char     *name;
+       unsigned short addr;
+       unsigned short width;
 } eice_regs[] = {
        [EICE_DBG_CTRL] = {
                .name =         "debug_ctrl",
@@ -206,8 +205,8 @@ struct reg_cache *embeddedice_build_reg_cache(struct target *target,
        for (i = 0; i < num_regs; i++) {
                reg_list[i].name = eice_regs[i].name;
                reg_list[i].size = eice_regs[i].width;
-               reg_list[i].dirty = 0;
-               reg_list[i].valid = 0;
+               reg_list[i].dirty = false;
+               reg_list[i].valid = false;
                reg_list[i].value = calloc(1, 4);
                reg_list[i].arch_info = &arch_info[i];
                reg_list[i].type = &eice_reg_type;
@@ -349,7 +348,7 @@ int embeddedice_read_reg_w_check(struct reg *reg,
        if (retval != ERROR_OK)
                return retval;
 
-       retval = arm_jtag_set_instr(ice_reg->jtag_info,
+       retval = arm_jtag_set_instr(ice_reg->jtag_info->tap,
                        ice_reg->jtag_info->intest_instr, NULL, TAP_IDLE);
        if (retval != ERROR_OK)
                return retval;
@@ -415,7 +414,7 @@ int embeddedice_receive(struct arm_jtag *jtag_info, uint32_t *data, uint32_t siz
        retval = arm_jtag_scann(jtag_info, 0x2, TAP_IDLE);
        if (retval != ERROR_OK)
                return retval;
-       retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
+       retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
        if (retval != ERROR_OK)
                return retval;
 
@@ -471,8 +470,8 @@ void embeddedice_set_reg(struct reg *reg, uint32_t value)
        embeddedice_write_reg(reg, value);
 
        buf_set_u32(reg->value, 0, reg->size, value);
-       reg->valid = 1;
-       reg->dirty = 0;
+       reg->valid = true;
+       reg->dirty = false;
 
 }
 
@@ -502,7 +501,7 @@ void embeddedice_write_reg(struct reg *reg, uint32_t value)
 
        arm_jtag_scann(ice_reg->jtag_info, 0x2, TAP_IDLE);
 
-       arm_jtag_set_instr(ice_reg->jtag_info, ice_reg->jtag_info->intest_instr, NULL, TAP_IDLE);
+       arm_jtag_set_instr(ice_reg->jtag_info->tap, ice_reg->jtag_info->intest_instr, NULL, TAP_IDLE);
 
        uint8_t reg_addr = ice_reg->addr & 0x1f;
        embeddedice_write_reg_inner(ice_reg->jtag_info->tap, reg_addr, value);
@@ -536,7 +535,7 @@ int embeddedice_send(struct arm_jtag *jtag_info, uint32_t *data, uint32_t size)
        retval = arm_jtag_scann(jtag_info, 0x2, TAP_IDLE);
        if (retval != ERROR_OK)
                return retval;
-       retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
+       retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
        if (retval != ERROR_OK)
                return retval;
 
@@ -578,8 +577,8 @@ int embeddedice_handshake(struct arm_jtag *jtag_info, int hsbit, uint32_t timeou
        uint8_t field2_out[1];
        int retval;
        uint32_t hsact;
-       struct timeval lap;
        struct timeval now;
+       struct timeval timeout_end;
 
        if (hsbit == EICE_COMM_CTRL_WBIT)
                hsact = 1;
@@ -593,7 +592,7 @@ int embeddedice_handshake(struct arm_jtag *jtag_info, int hsbit, uint32_t timeou
        retval = arm_jtag_scann(jtag_info, 0x2, TAP_IDLE);
        if (retval != ERROR_OK)
                return retval;
-       retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE);
+       retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
        if (retval != ERROR_OK)
                return retval;
 
@@ -612,7 +611,8 @@ int embeddedice_handshake(struct arm_jtag *jtag_info, int hsbit, uint32_t timeou
        fields[2].in_value = NULL;
 
        jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_IDLE);
-       gettimeofday(&lap, NULL);
+       gettimeofday(&timeout_end, NULL);
+       timeval_add_time(&timeout_end, 0, timeout * 1000);
        do {
                jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_IDLE);
                retval = jtag_execute_queue();
@@ -623,8 +623,7 @@ int embeddedice_handshake(struct arm_jtag *jtag_info, int hsbit, uint32_t timeou
                        return ERROR_OK;
 
                gettimeofday(&now, NULL);
-       } while ((uint32_t)((now.tv_sec - lap.tv_sec) * 1000
-                       + (now.tv_usec - lap.tv_usec) / 1000) <= timeout);
+       } while (timeval_compare(&now, &timeout_end) <= 0);
 
        LOG_ERROR("embeddedice handshake timeout");
        return ERROR_TARGET_TIMEOUT;

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)