warnings: fix alignment warnings
[openocd.git] / src / pld / virtex2.c
index e2ebb04143ec4b9a63b2d74c6586747d064bf447..f4657bcf48670636f74cf25b5233436592b86d52 100644 (file)
@@ -35,15 +35,15 @@ static int virtex2_set_instr(struct jtag_tap *tap, uint32_t new_instr)
        {
                struct scan_field field;
 
-               field.tap = tap;
                field.num_bits = tap->ir_length;
-               field.out_value = calloc(CEIL(field.num_bits, 8), 1);
-               buf_set_u32(field.out_value, 0, field.num_bits, new_instr);
+               void * t = calloc(DIV_ROUND_UP(field.num_bits, 8), 1);
+               field.out_value = t;
+               buf_set_u32(t, 0, field.num_bits, new_instr);
                field.in_value = NULL;
 
-               jtag_add_ir_scan(1, &field, jtag_set_end_state(TAP_IDLE));
+               jtag_add_ir_scan(tap, &field, TAP_IDLE);
 
-               free(field.out_value);
+               free(t);
        }
 
        return ERROR_OK;
@@ -59,7 +59,6 @@ static int virtex2_send_32(struct pld_device *pld_device,
 
        values = malloc(num_words * 4);
 
-       scan_field.tap = virtex2_info->tap;
        scan_field.num_bits = num_words * 32;
        scan_field.out_value = values;
        scan_field.in_value = NULL;
@@ -69,7 +68,7 @@ static int virtex2_send_32(struct pld_device *pld_device,
 
        virtex2_set_instr(virtex2_info->tap, 0x5); /* CFG_IN */
 
-       jtag_add_dr_scan(1, &scan_field, jtag_set_end_state(TAP_DRPAUSE));
+       jtag_add_dr_scan(virtex2_info->tap, 1, &scan_field, TAP_DRPAUSE);
 
        free(values);
 
@@ -79,7 +78,7 @@ static int virtex2_send_32(struct pld_device *pld_device,
 static __inline__ void virtexflip32(jtag_callback_data_t arg)
 {
   uint8_t *in = (uint8_t *)arg;
-       *((uint32_t *)in) = flip_u32(le_to_h_u32(in), 32);
+       *((uint32_t *)arg) = flip_u32(le_to_h_u32(in), 32);
 }
 
 static int virtex2_receive_32(struct pld_device *pld_device,
@@ -88,7 +87,6 @@ static int virtex2_receive_32(struct pld_device *pld_device,
        struct virtex2_pld_device *virtex2_info = pld_device->driver_priv;
        struct scan_field scan_field;
 
-       scan_field.tap = virtex2_info->tap;
        scan_field.num_bits = 32;
        scan_field.out_value = NULL;
        scan_field.in_value = NULL;
@@ -99,7 +97,7 @@ static int virtex2_receive_32(struct pld_device *pld_device,
        {
                scan_field.in_value = (uint8_t *)words;
 
-               jtag_add_dr_scan(1, &scan_field, jtag_set_end_state(TAP_DRPAUSE));
+               jtag_add_dr_scan(virtex2_info->tap, 1, &scan_field, TAP_DRPAUSE);
 
                jtag_add_callback(virtexflip32, (jtag_callback_data_t)words);
 
@@ -139,13 +137,11 @@ static int virtex2_load(struct pld_device *pld_device, const char *filename)
        unsigned int i;
        struct scan_field field;
 
-       field.tap = virtex2_info->tap;
        field.in_value = NULL;
 
        if ((retval = xilinx_read_bit_file(&bit_file, filename)) != ERROR_OK)
                return retval;
 
-       jtag_set_end_state(TAP_IDLE);
        virtex2_set_instr(virtex2_info->tap, 0xb); /* JPROG_B */
        jtag_execute_queue();
        jtag_add_sleep(1000);
@@ -159,18 +155,17 @@ static int virtex2_load(struct pld_device *pld_device, const char *filename)
        field.num_bits = bit_file.length * 8;
        field.out_value = bit_file.data;
 
-       jtag_add_dr_scan(1, &field, jtag_set_end_state(TAP_DRPAUSE));
+       jtag_add_dr_scan(virtex2_info->tap, 1, &field, TAP_DRPAUSE);
        jtag_execute_queue();
 
        jtag_add_tlr();
 
-       jtag_set_end_state(TAP_IDLE);
        virtex2_set_instr(virtex2_info->tap, 0xc); /* JSTART */
-       jtag_add_runtest(13, jtag_set_end_state(TAP_IDLE));
+       jtag_add_runtest(13, TAP_IDLE);
        virtex2_set_instr(virtex2_info->tap, 0x3f); /* BYPASS */
        virtex2_set_instr(virtex2_info->tap, 0x3f); /* BYPASS */
        virtex2_set_instr(virtex2_info->tap, 0xc); /* JSTART */
-       jtag_add_runtest(13, jtag_set_end_state(TAP_IDLE));
+       jtag_add_runtest(13, TAP_IDLE);
        virtex2_set_instr(virtex2_info->tap, 0x3f); /* BYPASS */
        jtag_execute_queue();
 
@@ -183,18 +178,18 @@ COMMAND_HANDLER(virtex2_handle_read_stat_command)
        struct virtex2_pld_device *virtex2_info;
        uint32_t status;
 
-       if (argc < 1)
+       if (CMD_ARGC < 1)
        {
-               command_print(cmd_ctx, "usage: virtex2 read_stat <num>");
+               command_print(CMD_CTX, "usage: virtex2 read_stat <num>");
                return ERROR_OK;
        }
 
        unsigned dev_id;
-       COMMAND_PARSE_NUMBER(uint, args[0], dev_id);
+       COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], dev_id);
        device = get_pld_device_by_num(dev_id);
        if (!device)
        {
-               command_print(cmd_ctx, "pld device '#%s' is out of bounds", args[0]);
+               command_print(CMD_CTX, "pld device '#%s' is out of bounds", CMD_ARGV[0]);
                return ERROR_OK;
        }
 
@@ -202,7 +197,7 @@ COMMAND_HANDLER(virtex2_handle_read_stat_command)
 
        virtex2_read_stat(device, &status);
 
-       command_print(cmd_ctx, "virtex2 status register: 0x%8.8" PRIx32 "", status);
+       command_print(CMD_CTX, "virtex2 status register: 0x%8.8" PRIx32 "", status);
 
        return ERROR_OK;
 }
@@ -213,15 +208,15 @@ PLD_DEVICE_COMMAND_HANDLER(virtex2_pld_device_command)
 
        struct virtex2_pld_device *virtex2_info;
 
-       if (argc < 2)
+       if (CMD_ARGC < 2)
        {
                LOG_WARNING("incomplete pld device 'virtex2' configuration");
                return ERROR_PLD_DEVICE_INVALID;
        }
 
-       tap = jtag_tap_by_string(args[1]);
+       tap = jtag_tap_by_string(CMD_ARGV[1]);
        if (tap == NULL) {
-               command_print(cmd_ctx, "Tap: %s does not exist", args[1]);
+               command_print(CMD_CTX, "Tap: %s does not exist", CMD_ARGV[1]);
                return ERROR_OK;
        }
 
@@ -233,21 +228,29 @@ PLD_DEVICE_COMMAND_HANDLER(virtex2_pld_device_command)
        return ERROR_OK;
 }
 
-static int virtex2_register_commands(struct command_context_s *cmd_ctx)
-{
-       command_t *virtex2_cmd = register_command(cmd_ctx, NULL, "virtex2",
-                       NULL, COMMAND_ANY, "virtex2 specific commands");
-
-       register_command(cmd_ctx, virtex2_cmd, "read_stat",
-                       &virtex2_handle_read_stat_command, COMMAND_EXEC,
-                       "read Virtex-II status register");
-
-       return ERROR_OK;
-}
+static const struct command_registration virtex2_exec_command_handlers[] = {
+       {
+               .name = "read_stat",
+               .mode = COMMAND_EXEC,
+               .handler = virtex2_handle_read_stat_command,
+               .help = "read status register",
+               .usage = "pld_num",
+       },
+       COMMAND_REGISTRATION_DONE
+};
+static const struct command_registration virtex2_command_handler[] = {
+       {
+               .name = "virtex2",
+               .mode = COMMAND_ANY,
+               .help = "Virtex-II specific commands",
+               .chain = virtex2_exec_command_handlers,
+       },
+       COMMAND_REGISTRATION_DONE
+};
 
 struct pld_driver virtex2_pld = {
                .name = "virtex2",
-               .register_commands = &virtex2_register_commands,
+               .commands = virtex2_command_handler,
                .pld_device_command = &virtex2_pld_device_command,
                .load = &virtex2_load,
        };

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)