remove register_callbacks from jtag interface
[openocd.git] / src / jtag / rlink / rlink.c
index 554cca29311bfdb278ea7c2681ab06a48370d412..bb33ad8fa028a209413ac38900cf8e14d085c61e 100644 (file)
@@ -2,7 +2,7 @@
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
- *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
+ *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
  *   oyvind.harboe@zylin.com                                               *
  *                                                                         *
  *   Copyright (C) 2008 Rob Brown, Lou Deluxe                              *
@@ -34,9 +34,7 @@
 #include "st7.h"
 #include "ep1_cmd.h"
 #include "dtc_cmd.h"
-
-/* system includes */
-#include <usb.h>
+#include "usb_common.h"
 
 
 /* This feature is made useless by running the DTC all the time.  When automatic, the LED is on whenever the DTC is running.  Otherwise, USB messages are sent to turn it on and off. */
@@ -121,14 +119,14 @@ ep1_generic_commandl(
        va_list         ap;
        int             usb_ret;
 
-       if(length > sizeof(usb_buffer)) {
+       if (length > sizeof(usb_buffer)) {
                length = sizeof(usb_buffer);
        }
 
        usb_buffer_p = usb_buffer;
 
        va_start(ap, length);
-       while(length > 0) {
+       while (length > 0) {
                *usb_buffer_p++ = va_arg(ap, int);
                length--;
        }
@@ -137,14 +135,14 @@ ep1_generic_commandl(
                usb_buffer_p,
                0,
                sizeof(usb_buffer) - (usb_buffer_p - usb_buffer)
-       );
+);
 
        usb_ret = usb_bulk_write(
                pHDev,
                USB_EP1OUT_ADDR,
                (char *)usb_buffer, sizeof(usb_buffer),
                USB_TIMEOUT_MS
-       );
+);
 
        return(usb_ret);
 }
@@ -170,13 +168,13 @@ ep1_memory_read(
                usb_buffer + 4,
                0,
                sizeof(usb_buffer) - 4
-       );
+);
 
        remain = length;
        count = 0;
 
-       while(remain) {
-               if(remain > sizeof(usb_buffer)) {
+       while (remain) {
+               if (remain > sizeof(usb_buffer)) {
                        length = sizeof(usb_buffer);
                } else {
                        length = remain;
@@ -190,9 +188,9 @@ ep1_memory_read(
                        pHDev, USB_EP1OUT_ADDR,
                        usb_buffer, sizeof(usb_buffer),
                        USB_TIMEOUT_MS
-               );
+);
 
-               if(usb_ret < sizeof(usb_buffer)) {
+               if (usb_ret < sizeof(usb_buffer)) {
                        break;
                }
 
@@ -200,9 +198,9 @@ ep1_memory_read(
                        pHDev, USB_EP1IN_ADDR,
                        buffer, length,
                        USB_TIMEOUT_MS
-               );
+);
 
-               if(usb_ret < length) {
+               if (usb_ret < length) {
                        break;
                }
 
@@ -236,8 +234,8 @@ ep1_memory_write(
        remain = length;
        count = 0;
 
-       while(remain) {
-               if(remain > (sizeof(usb_buffer) - 4)) {
+       while (remain) {
+               if (remain > (sizeof(usb_buffer) - 4)) {
                        length = (sizeof(usb_buffer) - 4);
                } else {
                        length = remain;
@@ -250,20 +248,20 @@ ep1_memory_write(
                        usb_buffer + 4,
                        buffer,
                        length
-               );
+);
                memset(
                        usb_buffer + 4 + length,
                        0,
                        sizeof(usb_buffer) - 4 - length
-               );
+);
 
                        usb_ret = usb_bulk_write(
                        pHDev, USB_EP1OUT_ADDR,
                        (char *)usb_buffer, sizeof(usb_buffer),
                        USB_TIMEOUT_MS
-               );
+);
 
-               if((size_t)usb_ret < sizeof(usb_buffer)) {
+               if ((size_t)usb_ret < sizeof(usb_buffer)) {
                        break;
                }
 
@@ -291,7 +289,7 @@ ep1_memory_writel(
        va_list         ap;
        size_t          remain;
 
-       if(length > sizeof(buffer)) {
+       if (length > sizeof(buffer)) {
                length = sizeof(buffer);
        }
 
@@ -299,7 +297,7 @@ ep1_memory_writel(
        buffer_p = buffer;
 
        va_start(ap, length);
-       while(remain > 0) {
+       while (remain > 0) {
                *buffer_p++ = va_arg(ap, int);
                remain--;
        }
@@ -327,17 +325,17 @@ static
 int
 dtc_load_from_buffer(
        usb_dev_handle  *pHDev,
-       const u8                *buffer,
+       const uint8_t           *buffer,
        size_t                  length
 ) {
        struct header_s {
-               u8      type;
-               u8      length;
+               uint8_t type;
+               uint8_t length;
        };
 
        int                             usb_err;
        struct header_s *header;
-       u8                              lut_start = 0xc0;
+       uint8_t                         lut_start = 0xc0;
 
        dtc_entry_download = 0;
 
@@ -345,11 +343,11 @@ dtc_load_from_buffer(
        usb_err = ep1_generic_commandl(
                pHDev, 1,
                EP1_CMD_DTC_STOP
-       );
-       if(usb_err < 0) return(usb_err);
+);
+       if (usb_err < 0) return(usb_err);
 
-       while(length) {
-               if(length < sizeof(*header)) {
+       while (length) {
+               if (length < sizeof(*header)) {
                        LOG_ERROR("Malformed DTC image\n");
                        exit(1);
                }
@@ -358,18 +356,18 @@ dtc_load_from_buffer(
                buffer += sizeof(*header);
                length -= sizeof(*header);
 
-               if(length < (size_t)header->length + 1) {
+               if (length < (size_t)header->length + 1) {
                        LOG_ERROR("Malformed DTC image\n");
                        exit(1);
                }
 
-               switch(header->type) {
+               switch (header->type) {
                        case DTCLOAD_COMMENT:
                                break;
 
                        case DTCLOAD_ENTRY:
                                /* store entry addresses somewhere */
-                               if(!strncmp("download", (char *)buffer + 1, 8)) {
+                               if (!strncmp("download", (char *)buffer + 1, 8)) {
                                        dtc_entry_download = buffer[0];
                                }
                                break;
@@ -380,8 +378,8 @@ dtc_load_from_buffer(
                                        pHDev,
                                        DTC_LOAD_BUFFER,
                                        header->length + 1, buffer
-                               );
-                               if(usb_err < 0) return(usb_err);
+);
+                               if (usb_err < 0) return(usb_err);
 
                                /* Load it into the DTC. */
                                usb_err = ep1_generic_commandl(
@@ -389,8 +387,8 @@ dtc_load_from_buffer(
                                        EP1_CMD_DTC_LOAD,
                                                (DTC_LOAD_BUFFER >> 8),
                                                DTC_LOAD_BUFFER
-                               );
-                               if(usb_err < 0) return(usb_err);
+);
+                               if (usb_err < 0) return(usb_err);
 
                                break;
 
@@ -400,8 +398,8 @@ dtc_load_from_buffer(
                                        EP1_CMD_DTC_CALL,
                                                buffer[0],
                                        EP1_CMD_DTC_WAIT
-                               );
-                               if(usb_err < 0) return(usb_err);
+);
+                               if (usb_err < 0) return(usb_err);
 
                                break;
 
@@ -414,8 +412,8 @@ dtc_load_from_buffer(
                                        pHDev,
                                        ST7_USB_BUF_EP0OUT + lut_start,
                                        header->length + 1, buffer
-                               );
-                               if(usb_err < 0) return(usb_err);
+);
+                               if (usb_err < 0) return(usb_err);
                                break;
 
                        default:
@@ -439,7 +437,7 @@ static
 int
 dtc_start_download(void) {
        int     usb_err;
-       u8      ep2txr;
+       uint8_t ep2txr;
 
        /* set up for download mode and make sure EP2 is set up to transmit */
        usb_err = ep1_generic_commandl(
@@ -452,16 +450,16 @@ dtc_start_download(void) {
                        ST7_EP2TXR >> 8,
                        ST7_EP2TXR,
                        1
-       );
-       if(usb_err < 0) return(usb_err);
+);
+       if (usb_err < 0) return(usb_err);
 
        /* read back ep2txr */
        usb_err = usb_bulk_read(
                pHDev, USB_EP1IN_ADDR,
                (char *)&ep2txr, 1,
                USB_TIMEOUT_MS
-       );
-       if(usb_err < 0) return(usb_err);
+);
+       if (usb_err < 0) return(usb_err);
 
        usb_err = ep1_generic_commandl(
                pHDev, 13,
@@ -479,15 +477,15 @@ dtc_start_download(void) {
                EP1_CMD_DTC_CALL,       /* start running the DTC */
                        dtc_entry_download,
                EP1_CMD_DTC_GET_CACHED_STATUS
-       );
-       if(usb_err < 0) return(usb_err);
+);
+       if (usb_err < 0) return(usb_err);
 
        /* wait for completion */
        usb_err = usb_bulk_read(
                pHDev, USB_EP1IN_ADDR,
                (char *)&ep2txr, 1,
                USB_TIMEOUT_MS
-       );
+);
 
        return(usb_err);
 }
@@ -497,12 +495,12 @@ static
 int
 dtc_run_download(
        usb_dev_handle  *pHDev,
-       u8      *command_buffer,
+       uint8_t *command_buffer,
        int     command_buffer_size,
-       u8      *reply_buffer,
+       uint8_t *reply_buffer,
        int     reply_buffer_size
 ) {
-       u8      ep2_buffer[USB_EP2IN_SIZE];
+       uint8_t ep2_buffer[USB_EP2IN_SIZE];
        int     usb_err;
        int     i;
 
@@ -513,12 +511,12 @@ dtc_run_download(
                USB_EP2OUT_ADDR,
                (char *)command_buffer, USB_EP2BANK_SIZE,
                USB_TIMEOUT_MS
-       );
-       if(usb_err < 0) return(usb_err);
+);
+       if (usb_err < 0) return(usb_err);
 
 
        /* Wait for DTC to finish running command buffer */
-       for(i = 10;;) {
+       for (i = 10;;) {
                usb_err = ep1_generic_commandl(
                        pHDev, 4,
 
@@ -526,41 +524,41 @@ dtc_run_download(
                                DTC_STATUS_POLL_BYTE >> 8,
                                DTC_STATUS_POLL_BYTE,
                                1
-               );
-               if(usb_err < 0) return(usb_err);
+);
+               if (usb_err < 0) return(usb_err);
 
                usb_err = usb_bulk_read(
                        pHDev,
                        USB_EP1IN_ADDR,
                        (char *)ep2_buffer, 1,
                        USB_TIMEOUT_MS
-               );
-               if(usb_err < 0) return(usb_err);
+);
+               if (usb_err < 0) return(usb_err);
 
-               if(ep2_buffer[0] & 0x01) break;
+               if (ep2_buffer[0] & 0x01) break;
 
-               if(!--i) {
+               if (!--i) {
                        LOG_ERROR("%s, %d: too many retries waiting for DTC status\n",
                                __FILE__, __LINE__
-                       );
+);
                        return(-ETIMEDOUT);
                }
        }
 
 
-       if(!reply_buffer) reply_buffer_size = 0;
-       if(reply_buffer_size) {
+       if (!reply_buffer) reply_buffer_size = 0;
+       if (reply_buffer_size) {
                usb_err = usb_bulk_read(
                        pHDev,
                        USB_EP2IN_ADDR,
                        (char *)ep2_buffer, sizeof(ep2_buffer),
                        USB_TIMEOUT_MS
-               );
+);
 
-               if(usb_err < (int)sizeof(ep2_buffer)) {
+               if (usb_err < (int)sizeof(ep2_buffer)) {
                        LOG_ERROR("%s, %d: Read of endpoint 2 returned %d\n",
                                __FILE__, __LINE__, usb_err
-                       );
+);
                        return(usb_err);
                }
 
@@ -576,19 +574,18 @@ dtc_run_download(
  * The dtc reply queue is a singly linked list that describes what to do with the reply packet that comes from the DTC.  Only SCAN_IN and SCAN_IO generate these entries.
  */
 
-typedef
-struct dtc_reply_queue_entry_s {
-       struct dtc_reply_queue_entry_s  *next;
-       jtag_command_t  *cmd;   /* the command that resulted in this entry */
+struct dtc_reply_queue_entry {
+       struct dtc_reply_queue_entry    *next;
+       struct jtag_command     *cmd;   /* the command that resulted in this entry */
 
        struct {
-               u8              *buffer;        /* the scan buffer */
+               uint8_t         *buffer;        /* the scan buffer */
                int             size;           /* size of the scan buffer in bits */
                int             offset;         /* how many bits were already done before this? */
                int             length;         /* how many bits are processed in this operation? */
                enum scan_type  type;           /* SCAN_IN/SCAN_OUT/SCAN_IO */
        } scan;
-} dtc_reply_queue_entry_t;
+};
 
 
 /*
@@ -598,11 +595,11 @@ struct dtc_reply_queue_entry_s {
 
 static
 struct {
-       dtc_reply_queue_entry_t *rq_head;
-       dtc_reply_queue_entry_t *rq_tail;
-       u32                     cmd_index;
-       u32                     reply_index;
-       u8                      cmd_buffer[USB_EP2BANK_SIZE];
+       struct dtc_reply_queue_entry    *rq_head;
+       struct dtc_reply_queue_entry    *rq_tail;
+       uint32_t                        cmd_index;
+       uint32_t                        reply_index;
+       uint8_t                 cmd_buffer[USB_EP2BANK_SIZE];
 } dtc_queue;
 
 
@@ -612,8 +609,8 @@ struct {
 
 static
 struct {
-       u32     length;
-       u32     buffer;
+       uint32_t        length;
+       uint32_t        buffer;
 } tap_state_queue;
 
 
@@ -631,19 +628,19 @@ dtc_queue_init(void) {
 
 static
 inline
-dtc_reply_queue_entry_t *
+struct dtc_reply_queue_entry *
 dtc_queue_enqueue_reply(
        enum scan_type  type,
-       u8                              *buffer,
+       uint8_t                         *buffer,
        int                             size,
        int                             offset,
        int                             length,
-       jtag_command_t  *cmd
+       struct jtag_command     *cmd
 ) {
-       dtc_reply_queue_entry_t *rq_entry;
+       struct dtc_reply_queue_entry    *rq_entry;
 
-       rq_entry = malloc(sizeof(dtc_reply_queue_entry_t));
-       if(rq_entry != NULL) {
+       rq_entry = malloc(sizeof(struct dtc_reply_queue_entry));
+       if (rq_entry != NULL) {
                rq_entry->scan.type = type;
                rq_entry->scan.buffer = buffer;
                rq_entry->scan.size = size;
@@ -652,7 +649,7 @@ dtc_queue_enqueue_reply(
                rq_entry->cmd = cmd;
                rq_entry->next = NULL;
 
-               if(dtc_queue.rq_head == NULL)
+               if (dtc_queue.rq_head == NULL)
                        dtc_queue.rq_head = rq_entry;
                else
                        dtc_queue.rq_tail->next = rq_entry;
@@ -672,28 +669,28 @@ dtc_queue_enqueue_reply(
 static
 int
 dtc_queue_run(void) {
-       dtc_reply_queue_entry_t *rq_p, *rq_next;
+       struct dtc_reply_queue_entry    *rq_p, *rq_next;
        int                     retval;
        int                     usb_err;
        int                     bit_cnt;
        int                     x;
-       u8                      *dtc_p, *tdo_p;
-       u8                      dtc_mask, tdo_mask;
-       u8                      reply_buffer[USB_EP2IN_SIZE];
+       uint8_t                 *dtc_p, *tdo_p;
+       uint8_t                 dtc_mask, tdo_mask;
+       uint8_t                 reply_buffer[USB_EP2IN_SIZE];
 
        retval = ERROR_OK;
 
-       if(dtc_queue.cmd_index < 1) return(retval);
+       if (dtc_queue.cmd_index < 1) return(retval);
 
        dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = DTC_CMD_STOP;
 
        /* run the cmd */
-       if(dtc_queue.rq_head == NULL) {
+       if (dtc_queue.rq_head == NULL) {
                usb_err = dtc_run_download(pHDev,
                        dtc_queue.cmd_buffer, dtc_queue.cmd_index,
                        NULL, 0
-               );
-               if(usb_err < 0) {
+);
+               if (usb_err < 0) {
                        LOG_ERROR("dtc_run_download: %s\n", usb_strerror());
                        exit(1);
                }
@@ -701,8 +698,8 @@ dtc_queue_run(void) {
                usb_err = dtc_run_download(pHDev,
                        dtc_queue.cmd_buffer, dtc_queue.cmd_index,
                        reply_buffer, dtc_queue.reply_index
-               );
-               if(usb_err < 0) {
+);
+               if (usb_err < 0) {
                        LOG_ERROR("dtc_run_download: %s\n", usb_strerror());
                        exit(1);
                } else {
@@ -711,40 +708,40 @@ dtc_queue_run(void) {
 
                        /* The rigamarole with the masks and doing it bit-by-bit is due to the fact that the scan buffer is LSb-first and the DTC code is MSb-first for hardware reasons.   It was that or craft a function to do the reversal, and that wouldn't work with bit-stuffing (supplying extra bits to use mostly byte operations), or any other scheme which would throw the byte alignment off. */
 
-                       for(
+                       for (
                                rq_p = dtc_queue.rq_head;
                                rq_p != NULL;
                                rq_p = rq_next
-                       ) {
+) {
                                tdo_p = rq_p->scan.buffer + (rq_p->scan.offset / 8);
                                tdo_mask = 1 << (rq_p->scan.offset % 8);
 
 
                                bit_cnt = rq_p->scan.length;
-                               if(bit_cnt >= 8) {
+                               if (bit_cnt >= 8) {
                                        /* bytes */
 
                                        dtc_mask = 1 << (8 - 1);
 
-                                       for(
+                                       for (
                                                ;
                                                bit_cnt;
                                                bit_cnt--
-                                       ) {
-                                               if(*dtc_p & dtc_mask) {
+) {
+                                               if (*dtc_p & dtc_mask) {
                                                        *tdo_p |= tdo_mask;
                                                } else {
                                                        *tdo_p &=~ tdo_mask;
                                                }
 
                                                dtc_mask >>= 1;
-                                               if(dtc_mask == 0) {
+                                               if (dtc_mask == 0) {
                                                        dtc_p++;
                                                        dtc_mask = 1 << (8 - 1);
                                                }
 
                                                tdo_mask <<= 1;
-                                               if(tdo_mask == 0) {
+                                               if (tdo_mask == 0) {
                                                        tdo_p++;
                                                        tdo_mask = 1;
                                                }
@@ -753,23 +750,23 @@ dtc_queue_run(void) {
                                        /*  extra bits or last bit */
 
                                        x = *dtc_p++;
-                                       if((
+                                       if ((
                                                rq_p->scan.type == SCAN_IN
-                                       ) && (
+) && (
                                                rq_p->scan.offset != rq_p->scan.size - 1
-                                       )) {
+)) {
                                                /* extra bits were sent as a full byte with padding on the end */
                                                dtc_mask = 1 << (8 - 1);
                                        } else {
                                                dtc_mask = 1 << (bit_cnt - 1);
                                        }
 
-                                       for(
+                                       for (
                                                ;
                                                bit_cnt;
                                                bit_cnt--
-                                       ) {
-                                               if(x & dtc_mask) {
+) {
+                                               if (x & dtc_mask) {
                                                        *tdo_p |= tdo_mask;
                                                } else {
                                                        *tdo_p &=~ tdo_mask;
@@ -778,7 +775,7 @@ dtc_queue_run(void) {
                                                dtc_mask >>= 1;
 
                                                tdo_mask <<= 1;
-                                               if(tdo_mask == 0) {
+                                               if (tdo_mask == 0) {
                                                        tdo_p++;
                                                        tdo_mask = 1;
                                                }
@@ -786,9 +783,9 @@ dtc_queue_run(void) {
                                        }
                                }
 
-                               if((rq_p->scan.offset + rq_p->scan.length) >= rq_p->scan.size) {
+                               if ((rq_p->scan.offset + rq_p->scan.length) >= rq_p->scan.size) {
                                        /* feed scan buffer back into openocd and free it */
-                                       if(jtag_read_buffer(rq_p->scan.buffer, rq_p->cmd->cmd.scan) != ERROR_OK) {
+                                       if (jtag_read_buffer(rq_p->scan.buffer, rq_p->cmd->cmd.scan) != ERROR_OK) {
                                                 retval = ERROR_JTAG_QUEUE_FAILED;
                                        }
                                        free(rq_p->scan.buffer);
@@ -827,31 +824,31 @@ int
 tap_state_queue_run(void) {
        int     i;
        int     bits;
-       u8      byte;
+       uint8_t byte;
        int     retval;
 
        retval = 0;
-       if(!tap_state_queue.length) return(retval);
+       if (!tap_state_queue.length) return(retval);
        bits = 1;
        byte = 0;
-       for(i = tap_state_queue.length; i--;) {
+       for (i = tap_state_queue.length; i--;) {
 
                byte <<= 1;
-               if(tap_state_queue.buffer & 1) {
+               if (tap_state_queue.buffer & 1) {
                        byte |= 1;
                }
-               if((bits >= 8) || !i) {
+               if ((bits >= 8) || !i) {
                        byte <<= (8 - bits);
 
                        /* make sure there's room for stop, byte op, and one byte */
-                       if(dtc_queue.cmd_index >= (sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))) {
+                       if (dtc_queue.cmd_index >= (sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))) {
                                dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
                                        DTC_CMD_STOP;
                                dtc_queue_run();
                        }
 
 #ifdef USE_HARDWARE_SHIFTER_FOR_TMS
-                       if(bits == 8) {
+                       if (bits == 8) {
                                dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
                                        DTC_CMD_SHIFT_TMS_BYTES(1);
                        } else {
@@ -881,16 +878,16 @@ tap_state_queue_run(void) {
 static
 int
 tap_state_queue_append(
-       u8      tms
+       uint8_t tms
 ) {
        int     retval;
 
-       if(tap_state_queue.length >= sizeof(tap_state_queue.buffer) * 8) {
+       if (tap_state_queue.length >= sizeof(tap_state_queue.buffer) * 8) {
                retval = tap_state_queue_run();
-               if(retval != 0) return(retval);
+               if (retval != 0) return(retval);
        }
 
-       if(tms) {
+       if (tms) {
                tap_state_queue.buffer |= (1 << tap_state_queue.length);
        }
        tap_state_queue.length++;
@@ -915,8 +912,8 @@ void rlink_end_state(tap_state_t state)
 static
 void rlink_state_move(void) {
 
-       int i=0, tms=0;
-       u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
+       int i = 0, tms = 0;
+       uint8_t tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
        int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
 
        for (i = 0; i < tms_count; i++)
@@ -929,7 +926,7 @@ void rlink_state_move(void) {
 }
 
 static
-void rlink_path_move(pathmove_command_t *cmd)
+void rlink_path_move(struct pathmove_command *cmd)
 {
        int num_states = cmd->num_states;
        int state_count;
@@ -994,7 +991,7 @@ void rlink_runtest(int num_cycles)
 static
 void rlink_reset(int trst, int srst)
 {
-       u8                      bitmap;
+       uint8_t                 bitmap;
        int                     usb_err;
 
        /* Read port A for bit op */
@@ -1004,8 +1001,8 @@ void rlink_reset(int trst, int srst)
                        ST7_PADR >> 8,
                        ST7_PADR,
                        1
-       );
-       if(usb_err < 0) {
+);
+       if (usb_err < 0) {
                LOG_ERROR("%s", usb_strerror());
                exit(1);
        }
@@ -1014,13 +1011,13 @@ void rlink_reset(int trst, int srst)
                pHDev, USB_EP1IN_ADDR,
                (char *)&bitmap, 1,
                USB_TIMEOUT_MS
-       );
-       if(usb_err < 1) {
+);
+       if (usb_err < 1) {
                LOG_ERROR("%s", usb_strerror());
                exit(1);
        }
 
-       if(trst) {
+       if (trst) {
                bitmap &= ~ST7_PA_NTRST;
        } else {
                bitmap |= ST7_PA_NTRST;
@@ -1039,8 +1036,8 @@ void rlink_reset(int trst, int srst)
                        ST7_PBDDR >> 8,
                        ST7_PBDDR,
                        1
-       );
-       if(usb_err < 0) {
+);
+       if (usb_err < 0) {
                LOG_ERROR("%s", usb_strerror());
                exit(1);
        }
@@ -1049,13 +1046,13 @@ void rlink_reset(int trst, int srst)
                pHDev, USB_EP1IN_ADDR,
                (char *)&bitmap, 1,
                USB_TIMEOUT_MS
-       );
-       if(usb_err < 1) {
+);
+       if (usb_err < 1) {
                LOG_ERROR("%s", usb_strerror());
                exit(1);
        }
 
-       if(srst) {
+       if (srst) {
                bitmap |= ST7_PB_NSRST;
        } else {
                bitmap &= ~ST7_PB_NSRST;
@@ -1070,8 +1067,8 @@ void rlink_reset(int trst, int srst)
                        1,
                        bitmap,
                EP1_CMD_DTC_GET_CACHED_STATUS
-       );
-       if(usb_err < 0) {
+);
+       if (usb_err < 0) {
                LOG_ERROR("%s", usb_strerror());
                exit(1);
        }
@@ -1080,8 +1077,8 @@ void rlink_reset(int trst, int srst)
                pHDev, USB_EP1IN_ADDR,
                (char *)&bitmap, 1,
                USB_TIMEOUT_MS
-       );
-       if(usb_err < 1) {
+);
+       if (usb_err < 1) {
                LOG_ERROR("%s", usb_strerror());
                exit(1);
        }
@@ -1091,9 +1088,9 @@ void rlink_reset(int trst, int srst)
 static
 int
 rlink_scan(
-       jtag_command_t  *cmd,
+       struct jtag_command     *cmd,
        enum scan_type  type,
-       u8                      *buffer,
+       uint8_t                 *buffer,
        int                     scan_size
 ) {
        bool            ir_scan;
@@ -1105,10 +1102,10 @@ rlink_scan(
        int                     x;
 
        int                     tdi_bit_offset;
-       u8                      tdi_mask, *tdi_p;
-       u8                      dtc_mask;
+       uint8_t                 tdi_mask, *tdi_p;
+       uint8_t                 dtc_mask;
 
-       if(scan_size < 1) {
+       if (scan_size < 1) {
                LOG_ERROR("scan_size cannot be less than 1 bit\n");
                exit(1);
        }
@@ -1120,7 +1117,7 @@ rlink_scan(
                (!ir_scan && (tap_get_state() == TAP_DRSHIFT))
                ||
                (ir_scan && (tap_get_state() == TAP_IRSHIFT))
-       )) {
+)) {
                saved_end_state = tap_get_end_state();
                rlink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT);
                rlink_state_move();
@@ -1131,7 +1128,7 @@ rlink_scan(
 
 
 #if 0
-       printf("scan_size = %d, type=0x%x\n", scan_size, type);
+       printf("scan_size = %d, type = 0x%x\n", scan_size, type);
        {
                int   i;
 
@@ -1140,7 +1137,7 @@ rlink_scan(
                buffer[scan_size / 8] &= ((1 << ((scan_size - 1) % 8) + 1) - 1);
 
                printf("before scan:");
-               for(i = 0; i < (scan_size + 7) / 8; i++) {
+               for (i = 0; i < (scan_size + 7) / 8; i++) {
                        printf(" %02x", buffer[i]);
                }
                printf("\n");
@@ -1156,28 +1153,28 @@ rlink_scan(
        tdi_p = buffer;
        tdi_mask = 1;
 
-       if(extra_bits && (type == SCAN_OUT)) {
+       if (extra_bits && (type == SCAN_OUT)) {
                /* Schedule any extra bits into the DTC command buffer, padding as needed */
                /* For SCAN_OUT, this comes before the full bytes so the (leading) padding bits will fall off the end */
                /* make sure there's room for stop, byte op, and one byte */
-               if(
+               if (
                        (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))
-               ) {
+) {
                        dtc_queue_run();
                }
 
                x = 0;
                dtc_mask = 1 << (extra_bits - 1);
 
-               while(extra_bits--) {
-                       if(*tdi_p & tdi_mask) {
+               while (extra_bits--) {
+                       if (*tdi_p & tdi_mask) {
                                x |= dtc_mask;
                        }
 
                        dtc_mask >>= 1;
 
                        tdi_mask <<= 1;
-                       if(tdi_mask == 0) {
+                       if (tdi_mask == 0) {
                                tdi_p++;
                                tdi_mask = 1;
                        }
@@ -1190,8 +1187,8 @@ rlink_scan(
        }
 
        /* Loop scheduling full bytes into the DTC command buffer */
-       while(byte_bits) {
-               if(type == SCAN_IN) {
+       while (byte_bits) {
+               if (type == SCAN_IN) {
                        /* make sure there's room for stop and byte op */
                        x = (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1));
                } else {
@@ -1199,40 +1196,40 @@ rlink_scan(
                        x = (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1));
                }
 
-               if(type != SCAN_OUT) {
+               if (type != SCAN_OUT) {
                        /* make sure there's room for at least one reply byte */
                        x |= (dtc_queue.reply_index >= USB_EP2IN_SIZE - (1));
                }
 
-               if(x) {
+               if (x) {
                        dtc_queue_run();
                }
 
                chunk_bits = byte_bits;
                /* we can only use up to 16 bytes at a time */
-               if(chunk_bits > (16 * 8)) chunk_bits = (16 * 8);
+               if (chunk_bits > (16 * 8)) chunk_bits = (16 * 8);
 
-               if(type != SCAN_IN) {
+               if (type != SCAN_IN) {
                        /* how much is there room for, considering stop and byte op? */
                        x = (sizeof(dtc_queue.cmd_buffer) - (dtc_queue.cmd_index + 1 + 1)) * 8;
-                       if(chunk_bits > x) chunk_bits = x;
+                       if (chunk_bits > x) chunk_bits = x;
                }
 
-               if(type != SCAN_OUT) {
+               if (type != SCAN_OUT) {
                        /* how much is there room for in the reply buffer? */
                        x = (USB_EP2IN_SIZE - dtc_queue.reply_index) * 8;
-                       if(chunk_bits > x) chunk_bits = x;
+                       if (chunk_bits > x) chunk_bits = x;
                }
 
                /* so the loop will end */
                byte_bits -= chunk_bits;
 
-               if(type != SCAN_OUT) {
-                       if(dtc_queue_enqueue_reply(
+               if (type != SCAN_OUT) {
+                       if (dtc_queue_enqueue_reply(
                                type, buffer, scan_size, tdi_bit_offset,
                                chunk_bits,
                                cmd
-                       ) == NULL) {
+) == NULL) {
                                LOG_ERROR("enqueuing DTC reply entry: %s\n", strerror(errno));
                                exit(1);
                        }
@@ -1243,7 +1240,7 @@ rlink_scan(
                /* chunk_bits is a multiple of 8, so there are no rounding issues. */
                chunk_bytes = chunk_bits / 8;
 
-               switch(type) {
+               switch (type) {
                        case SCAN_IN:
                                x = DTC_CMD_SHIFT_TDO_BYTES(chunk_bytes);
                                break;
@@ -1256,17 +1253,17 @@ rlink_scan(
                }
                dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = x;
 
-               if(type != SCAN_IN) {
+               if (type != SCAN_IN) {
                        x = 0;
                        dtc_mask = 1 << (8 - 1);
 
-                       while(chunk_bits--) {
-                               if(*tdi_p & tdi_mask) {
+                       while (chunk_bits--) {
+                               if (*tdi_p & tdi_mask) {
                                        x |= dtc_mask;
                                }
 
                                dtc_mask >>= 1;
-                               if(dtc_mask == 0) {
+                               if (dtc_mask == 0) {
                                        dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = x;
                                        dtc_queue.reply_index++;
                                        x = 0;
@@ -1274,7 +1271,7 @@ rlink_scan(
                                }
 
                                tdi_mask <<= 1;
-                               if(tdi_mask == 0) {
+                               if (tdi_mask == 0) {
                                        tdi_p++;
                                        tdi_mask = 1;
                                }
@@ -1282,29 +1279,29 @@ rlink_scan(
                }
        }
 
-       if(extra_bits && (type != SCAN_OUT)) {
+       if (extra_bits && (type != SCAN_OUT)) {
                /* Schedule any extra bits into the DTC command buffer */
                /* make sure there's room for stop, byte op, and one byte */
-               if(
+               if (
                        (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))
                        ||
                        (dtc_queue.reply_index >= USB_EP2IN_SIZE - (1))
-               ) {
+) {
                        dtc_queue_run();
                }
 
-               if(dtc_queue_enqueue_reply(
+               if (dtc_queue_enqueue_reply(
                        type, buffer, scan_size, tdi_bit_offset,
                        extra_bits,
                        cmd
-               ) == NULL) {
+) == NULL) {
                        LOG_ERROR("enqueuing DTC reply entry: %s\n", strerror(errno));
                        exit(1);
                }
 
                tdi_bit_offset += extra_bits;
 
-               if(type == SCAN_IN) {
+               if (type == SCAN_IN) {
                        dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
                                DTC_CMD_SHIFT_TDO_BYTES(1);
 
@@ -1315,15 +1312,15 @@ rlink_scan(
                        x = 0;
                        dtc_mask = 1 << (8 - 1);
 
-                       while(extra_bits--) {
-                               if(*tdi_p & tdi_mask) {
+                       while (extra_bits--) {
+                               if (*tdi_p & tdi_mask) {
                                        x |= dtc_mask;
                                }
 
                                dtc_mask >>= 1;
 
                                tdi_mask <<= 1;
-                               if(tdi_mask == 0) {
+                               if (tdi_mask == 0) {
                                        tdi_p++;
                                        tdi_mask = 1;
                                }
@@ -1338,24 +1335,24 @@ rlink_scan(
        /* Schedule the last bit into the DTC command buffer */
        {
                /* make sure there's room for stop, and bit pair command */
-               if(
+               if (
                        (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1))
                        ||
                        (dtc_queue.reply_index >= USB_EP2IN_SIZE - (1))
-               ) {
+) {
                        dtc_queue_run();
                }
 
-               if(type == SCAN_OUT) {
+               if (type == SCAN_OUT) {
                        dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
                                DTC_CMD_SHIFT_TMS_TDI_BIT_PAIR(1, (*tdi_p & tdi_mask), 0);
 
                } else {
-                       if(dtc_queue_enqueue_reply(
+                       if (dtc_queue_enqueue_reply(
                                type, buffer, scan_size, tdi_bit_offset,
                                1,
                                cmd
-                       ) == NULL) {
+) == NULL) {
                                LOG_ERROR("enqueuing DTC reply entry: %s\n", strerror(errno));
                                exit(1);
                        }
@@ -1379,10 +1376,10 @@ rlink_scan(
 static
 int rlink_execute_queue(void)
 {
-       jtag_command_t *cmd = jtag_command_queue; /* currently processed command */
+       struct jtag_command *cmd = jtag_command_queue; /* currently processed command */
        int scan_size;
        enum scan_type type;
-       u8 *buffer;
+       uint8_t *buffer;
        int retval, tmp_retval;
 
        /* return ERROR_OK, unless something goes wrong */
@@ -1393,7 +1390,7 @@ int rlink_execute_queue(void)
        ep1_generic_commandl(pHDev, 2,
                EP1_CMD_SET_PORTD_LEDS,
                ~(ST7_PD_NBUSY_LED)
-       );
+);
 #endif
 
        while (cmd)
@@ -1455,7 +1452,7 @@ int rlink_execute_queue(void)
                                        rlink_end_state(cmd->cmd.scan->end_state);
                                scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
                                type = jtag_scan_type(cmd->cmd.scan);
-                               if(rlink_scan(cmd, type, buffer, scan_size) != ERROR_OK) {
+                               if (rlink_scan(cmd, type, buffer, scan_size) != ERROR_OK) {
                                        retval = ERROR_FAIL;
                                }
                                break;
@@ -1475,7 +1472,7 @@ int rlink_execute_queue(void)
        /* Flush the DTC queue to make sure any pending reads have been done before exiting this function */
        tap_state_queue_run();
        tmp_retval = dtc_queue_run();
-       if(tmp_retval != ERROR_OK) {
+       if (tmp_retval != ERROR_OK) {
                retval = tmp_retval;
        }
 
@@ -1484,7 +1481,7 @@ int rlink_execute_queue(void)
        ep1_generic_commandl(pHDev, 2,
                EP1_CMD_SET_PORTD_LEDS,
                ~0
-       );
+);
 #endif
 
        return retval;
@@ -1498,23 +1495,23 @@ int rlink_speed(int speed)
 {
        int             i;
 
-       if(speed == 0) {
+       if (speed == 0) {
                /* fastest speed */
                speed = rlink_speed_table[rlink_speed_table_size - 1].prescaler;
        }
 
-       for(i = rlink_speed_table_size; i--; ) {
-               if(rlink_speed_table[i].prescaler == speed) {
-                       if(dtc_load_from_buffer(pHDev, rlink_speed_table[i].dtc, rlink_speed_table[i].dtc_size) != 0) {
+       for (i = rlink_speed_table_size; i--;) {
+               if (rlink_speed_table[i].prescaler == speed) {
+                       if (dtc_load_from_buffer(pHDev, rlink_speed_table[i].dtc, rlink_speed_table[i].dtc_size) != 0) {
                                LOG_ERROR("An error occurred while trying to load DTC code for speed \"%d\".\n", speed);
                                exit(1);
                        }
 
-                       if(dtc_start_download() < 0) {
+                       if (dtc_start_download() < 0) {
                                LOG_ERROR("%s, %d: starting DTC: %s",
                                        __FILE__, __LINE__,
                                        usb_strerror()
-                               );
+);
                                exit(1);
                        }
 
@@ -1534,8 +1531,8 @@ int rlink_speed_div(
 ) {
        int     i;
 
-       for(i = rlink_speed_table_size; i--; ) {
-               if(rlink_speed_table[i].prescaler == speed) {
+       for (i = rlink_speed_table_size; i--;) {
+               if (rlink_speed_table[i].prescaler == speed) {
                        *khz = rlink_speed_table[i].khz;
                        return(ERROR_OK);
                }
@@ -1553,13 +1550,13 @@ int rlink_khz(
 ) {
        int     i;
 
-       if(khz == 0) {
+       if (khz == 0) {
                LOG_ERROR("RCLK not supported");
                return ERROR_FAIL;
        }
 
-       for(i = rlink_speed_table_size; i--; ) {
-               if(rlink_speed_table[i].khz <= khz) {
+       for (i = rlink_speed_table_size; i--;) {
+               if (rlink_speed_table[i].khz <= khz) {
                        *speed = rlink_speed_table[i].prescaler;
                        return(ERROR_OK);
                }
@@ -1571,156 +1568,81 @@ int rlink_khz(
 }
 
 
-#if 0
-static
-int
-handle_dtc_directory_command(
-       struct command_context_s *cmd_ctx,
-       char *cmd,
-       char **args,
-       int argc
-) {
-       if(argc != 1) {
-               LOG_ERROR("expected exactly one argument to rlink_dtc_directory <directory-path>");
-               return(ERROR_INVALID_ARGUMENTS);
-       }
-
-       printf("handle_dtc_directory_command called with \"%s\"\n", args[0]);
-
-       return(ERROR_OK);
-}
-#endif
-
-
-static
-int rlink_register_commands(struct command_context_s *cmd_ctx)
-{
-
-#ifdef _DEBUG_JTAG_IO_
-       LOG_DEBUG("rlink_register_commands called with cmd_ctx=%p\n", cmd_ctx);
-#endif
-
-#if 0
-       register_command(
-               cmd_ctx, NULL,
-               "rlink_dtc_directory",
-               handle_dtc_directory_command,
-               COMMAND_CONFIG,
-               "The directory in which to search for DTC load images"
-       );
-#endif
-
-       return ERROR_OK;
-}
-
-
 static
 int rlink_init(void)
 {
-       struct usb_bus *busses;
-       struct usb_bus *bus;
        int i, j, retries;
-       int found=0;
-       int success=0;
-       u8 reply_buffer[USB_EP1IN_SIZE];
+       uint8_t reply_buffer[USB_EP1IN_SIZE];
 
        usb_init();
-       usb_find_busses();
-       usb_find_devices();
-
-       busses = usb_get_busses();
+       const uint16_t vids[] = { USB_IDVENDOR, 0 };
+       const uint16_t pids[] = { USB_IDPRODUCT, 0 };
+       if (jtag_usb_open(vids, pids, &pHDev) != ERROR_OK)
+               return ERROR_FAIL;
 
-       for(bus = busses; bus; bus = bus->next)
+       struct usb_device *dev = usb_device(pHDev);
+       if (dev->descriptor.bNumConfigurations > 1)
        {
-               struct usb_device *dev;
+               LOG_ERROR("Whoops! NumConfigurations is not 1, don't know what to do...\n");
+               return ERROR_FAIL;
+       }
+       if (dev->config->bNumInterfaces > 1)
+       {
+               LOG_ERROR("Whoops! NumInterfaces is not 1, don't know what to do...\n");
+               return ERROR_FAIL;
+       }
 
-               for(dev = bus->devices; dev; dev = dev->next)
-               {
-                       if( (dev->descriptor.idVendor == USB_IDVENDOR) && (dev->descriptor.idProduct == USB_IDPRODUCT) )
-                       {
-                               found = 1;
-                               LOG_DEBUG("Found device on bus.\n");
+       LOG_DEBUG("Opened device, pHDev = %p\n", pHDev);
 
-                               do
-                               {
-                                       if( dev->descriptor.bNumConfigurations > 1 )
-                                       {
-                                               LOG_ERROR("Whoops! NumConfigurations is not 1, don't know what to do...\n");
-                                               break;
-                                       }
-                                       if( dev->config->bNumInterfaces > 1 )
-                                       {
-                                               LOG_ERROR("Whoops! NumInterfaces is not 1, don't know what to do...\n");
-                                               break;
-                                       }
+       /* usb_set_configuration required under win32 */
+       usb_set_configuration(pHDev, dev->config[0].bConfigurationValue);
 
-                                       pHDev=usb_open(dev);
-                                       if( !pHDev )
-                                               LOG_ERROR ("Failed to open device.\n");
-                                       else
-                                       {
-                                               LOG_DEBUG("Opened device, pHDev = %p\n",pHDev);
-
-                                               /* usb_set_configuration required under win32 */
-                                               usb_set_configuration(pHDev, dev->config[0].bConfigurationValue);
-
-                                               retries = 3;
-                                               do
-                                               {
-                                                       i = usb_claim_interface(pHDev,0);
-                                                       if(i)
-                                                       {
-                                                               LOG_ERROR("usb_claim_interface: %s", usb_strerror());
+       retries = 3;
+       do
+       {
+               i = usb_claim_interface(pHDev,0);
+               if (i)
+               {
+                       LOG_ERROR("usb_claim_interface: %s", usb_strerror());
 #ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
-                                                               j = usb_detach_kernel_driver_np(pHDev, 0);
-                                                               if(j)
-                                                                       LOG_ERROR("detach kernel driver: %s", usb_strerror());
+                       j = usb_detach_kernel_driver_np(pHDev, 0);
+                       if (j)
+                               LOG_ERROR("detach kernel driver: %s", usb_strerror());
 #endif
-                                                       }
-                                                       else
-                                                       {
-                                                               LOG_DEBUG("interface claimed!\n");
-                                                               break;
-                                                       }
-                                               } while(--retries);
-
-                                               if(!i)
-                                               {
-                                                       if( usb_set_altinterface(pHDev,0) )
-                                                       {
-                                                               LOG_ERROR("Failed to set interface.\n");
-                                                               break;
-                                                       }
-                                                       else
-                                                               success=1;
-                                               }
-                                       }
-                               } while(0);
-                       }
                }
-       }
+               else
+               {
+                       LOG_DEBUG("interface claimed!\n");
+                       break;
+               }
+       } while (--retries);
 
-       if( !found )
+       if (i)
        {
-               LOG_ERROR("No device found on bus.\n");
-               exit(1);
+               LOG_ERROR("Initialisation failed.");
+               return ERROR_FAIL;
        }
-
-       if( !success )
+       if (usb_set_altinterface(pHDev,0) != 0)
        {
-               LOG_ERROR("Initialisation failed.");
-               exit(1);
+               LOG_ERROR("Failed to set interface.\n");
+               return ERROR_FAIL;
        }
 
-
-       /* The device starts out in an unknown state on open.  As such, result reads time out, and it's not even known whether the command was accepted.  So, for this first command, we issue it repeatedly until its response doesn't time out.  Also, if sending a command is going to time out, we'll find that out here. */
-       /* It must be possible to open the device in such a way that this special magic isn't needed, but, so far, it escapes us. */
-       for(i = 0; i < 5; i++) {
+       /* The device starts out in an unknown state on open.  As such,
+        * result reads time out, and it's not even known whether the
+        * command was accepted.  So, for this first command, we issue
+        * it repeatedly until its response doesn't time out.  Also, if
+        * sending a command is going to time out, we find that out here.
+        *
+        * It must be possible to open the device in such a way that
+        * this special magic isn't needed, but, so far, it escapes us.
+        */
+       for (i = 0; i < 5; i++) {
                j = ep1_generic_commandl(
                        pHDev, 1,
                        EP1_CMD_GET_FWREV
-               );
-               if(j < USB_EP1OUT_SIZE) {
+);
+               if (j < USB_EP1OUT_SIZE) {
                        LOG_ERROR("USB write error: %s", usb_strerror());
                        return(ERROR_FAIL);
                }
@@ -1728,17 +1650,17 @@ int rlink_init(void)
                        pHDev, USB_EP1IN_ADDR,
                        (char *)reply_buffer, sizeof(reply_buffer),
                        200
-               );
-               if(j != -ETIMEDOUT) break;
+);
+               if (j != -ETIMEDOUT) break;
        }
 
-       if(j < (int)sizeof(reply_buffer)) {
+       if (j < (int)sizeof(reply_buffer)) {
                LOG_ERROR("USB read error: %s", usb_strerror());
                return(ERROR_FAIL);
        }
        LOG_DEBUG(INTERFACE_NAME" firmware version: %d.%d.%d\n", reply_buffer[0], reply_buffer[1], reply_buffer[2]);
 
-       if((reply_buffer[0] != 0) || (reply_buffer[1] != 0) || (reply_buffer[2] != 3)) {
+       if ((reply_buffer[0] != 0) || (reply_buffer[1] != 0) || (reply_buffer[2] != 3)) {
                LOG_WARNING("The rlink device is not of the version that the developers have played with.  It may or may not work.\n");
        }
 
@@ -1761,15 +1683,15 @@ int rlink_init(void)
                        ST7_PEDR,
                        1,
                        ST7_PE_ADAPTER_SENSE_OUT
-       );
+);
 
        usb_bulk_read(
                pHDev, USB_EP1IN_ADDR,
                (char *)reply_buffer, 1,
                USB_TIMEOUT_MS
-       );
+);
 
-       if((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) != 0) {
+       if ((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) != 0) {
                LOG_WARNING("target detection problem\n");
        }
 
@@ -1786,16 +1708,16 @@ int rlink_init(void)
                        0x00,   /* DR */
                        0x00,   /* DDR */
                        0x00    /* OR */
-       );
+);
 
        usb_bulk_read(
                pHDev, USB_EP1IN_ADDR,
                (char *)reply_buffer, 1,
                USB_TIMEOUT_MS
-       );
+);
 
 
-       if((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) == 0) {
+       if ((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) == 0) {
                LOG_WARNING("target not plugged in\n");
        }
 
@@ -1813,7 +1735,7 @@ int rlink_init(void)
                        ST7_PBDDR,
                        1,
                        0x00
-       );
+);
 
        /* make sure DTC is stopped, set VPP control, set up ports A and B */
        ep1_generic_commandl(
@@ -1833,7 +1755,7 @@ int rlink_init(void)
                        ST7_PBDR,
                        1,
                        0x00
-       );
+);
 
        /* set LED updating mode and make sure they're unlit */
        ep1_generic_commandl(
@@ -1845,7 +1767,7 @@ int rlink_init(void)
 #endif
                EP1_CMD_SET_PORTD_LEDS,
                        ~0
-       );
+);
 
        tap_state_queue_init();
        dtc_queue_init();
@@ -1868,7 +1790,7 @@ int rlink_quit(void)
                        ~0,
                EP1_CMD_SET_PORTD_VPP,
                        ~0
-       );
+);
 
        usb_release_interface(pHDev,0);
        usb_close(pHDev);
@@ -1878,12 +1800,11 @@ int rlink_quit(void)
 }
 
 
-jtag_interface_t rlink_interface =
+struct jtag_interface rlink_interface =
 {
        .name = "rlink",
        .init = rlink_init,
        .quit = rlink_quit,
-       .register_commands = rlink_register_commands,
        .speed = rlink_speed,
        .speed_div = rlink_speed_div,
        .khz = rlink_khz,

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)