ipdbg: fix double free of virtual-ir data
[openocd.git] / src / pld / virtex2.c
index 5a8cf9d96e53f618cb14b170985ce74b14593855..3dff90621a3f093e9af2553b0d0374107224e35f 100644 (file)
@@ -265,7 +265,7 @@ static int virtex2_load(struct pld_device *pld_device, const char *filename)
        return retval;
 }
 
-COMMAND_HANDLER(virtex2_handle_program_command)
+COMMAND_HANDLER(virtex2_handle_refresh_command)
 {
        struct pld_device *device;
 
@@ -326,6 +326,21 @@ static int xilinx_get_ipdbg_hub(int user_num, struct pld_device *pld_device, str
        return ERROR_OK;
 }
 
+static int xilinx_get_jtagspi_userircode(struct pld_device *pld_device, unsigned int *ir)
+{
+       if (!pld_device || !pld_device->driver_priv)
+               return ERROR_FAIL;
+       struct virtex2_pld_device *pld_device_info = pld_device->driver_priv;
+
+       if (pld_device_info->command_set.num_user < 1) {
+               LOG_ERROR("code for command 'select user1' is unknown");
+               return ERROR_FAIL;
+       }
+
+       *ir = pld_device_info->command_set.user[0];
+       return ERROR_OK;
+}
+
 COMMAND_HANDLER(virtex2_handle_set_instuction_codes_command)
 {
        if (CMD_ARGC < 6 || CMD_ARGC > (6 + VIRTEX2_MAX_USER_INSTRUCTIONS))
@@ -347,7 +362,7 @@ COMMAND_HANDLER(virtex2_handle_set_instuction_codes_command)
        COMMAND_PARSE_NUMBER(u64, CMD_ARGV[3], instr_codes.jprog_b);
        COMMAND_PARSE_NUMBER(u64, CMD_ARGV[4], instr_codes.jstart);
        COMMAND_PARSE_NUMBER(u64, CMD_ARGV[5], instr_codes.jshutdown);
-       instr_codes.bypass = 0xffffffffffffffff;
+       instr_codes.bypass = 0xffffffffffffffffULL;
 
        unsigned int num_user = CMD_ARGC - 6;
        for (unsigned int i = 0; i < num_user; ++i)
@@ -434,10 +449,10 @@ static const struct command_registration virtex2_exec_command_handlers[] = {
                .help = "set instructions codes used for jtag-hub",
                .usage = "pld_name user1 [user2 [user3 [user4]]]",
        }, {
-               .name = "program",
+               .name = "refresh",
                .mode = COMMAND_EXEC,
-               .handler = virtex2_handle_program_command,
-               .help = "start loading of configuration (refresh)",
+               .handler = virtex2_handle_refresh_command,
+               .help = "start loading of configuration (program)",
                .usage = "pld_name",
        },
        COMMAND_REGISTRATION_DONE
@@ -460,4 +475,5 @@ struct pld_driver virtex2_pld = {
        .pld_create_command = &virtex2_pld_create_command,
        .load = &virtex2_load,
        .get_ipdbg_hub = xilinx_get_ipdbg_hub,
+       .get_jtagspi_userircode = xilinx_get_jtagspi_userircode,
 };

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)