jtag: opendous: fix tap buffer overflow
[openocd.git] / src / jtag / drivers / opendous.c
index 3a6cf5c693bad67bb929adccb8dc2f84751cffa4..efb6cf256d467e0fe04f87168c95881a275808e2 100644 (file)
@@ -86,9 +86,6 @@ static uint8_t usb_out_buffer[OPENDOUS_OUT_BUFFER_SIZE];
 
 /* External interface functions */
 static int opendous_execute_queue(void);
-static int opendous_speed(int speed);
-static int opendous_speed_div(int speed, int *khz);
-static int opendous_khz(int khz, int *jtag_speed);
 static int opendous_init(void);
 static int opendous_quit(void);
 
@@ -194,9 +191,6 @@ struct jtag_interface opendous_interface = {
        .name = "opendous",
        .commands = opendous_command_handlers,
        .execute_queue = opendous_execute_queue,
-       .speed = opendous_speed,
-       .speed_div = opendous_speed_div,
-       .khz = opendous_khz,
        .init = opendous_init,
        .quit = opendous_quit,
 };
@@ -276,33 +270,6 @@ static int opendous_execute_queue(void)
        return opendous_tap_execute();
 }
 
-/* Sets speed in kHz. */
-static int opendous_speed(int speed)
-{
-       if (speed <= OPENDOUS_MAX_SPEED) {
-               /* one day... */
-               return ERROR_OK;
-       } else
-               LOG_INFO("Requested speed %dkHz exceeds maximum of %dkHz, ignored", speed, OPENDOUS_MAX_SPEED);
-
-       return ERROR_OK;
-}
-
-static int opendous_speed_div(int speed, int *khz)
-{
-       *khz = speed;
-
-       return ERROR_OK;
-}
-
-static int opendous_khz(int khz, int *jtag_speed)
-{
-       *jtag_speed = khz;
-       /* TODO: convert this into delay value for opendous */
-
-       return ERROR_OK;
-}
-
 static int opendous_init(void)
 {
        int check_cnt;
@@ -515,8 +482,9 @@ void opendous_tap_init(void)
 void opendous_tap_ensure_space(int scans, int bits)
 {
        int available_scans = MAX_PENDING_SCAN_RESULTS - pending_scan_results_length;
+       int available_bits = OPENDOUS_TAP_BUFFER_SIZE / 2 - tap_length;
 
-       if (scans > available_scans)
+       if ((scans > available_scans) || (bits > available_bits))
                opendous_tap_execute();
 }
 
@@ -526,6 +494,8 @@ void opendous_tap_append_step(int tms, int tdi)
        unsigned char _tms = tms ? 1 : 0;
        unsigned char _tdi = tdi ? 1 : 0;
 
+       opendous_tap_ensure_space(0, 1);
+
        int tap_index =  tap_length / 4;
        int bits  = (tap_length % 4) * 2;
 

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)