Convert DEBUG_JTAG_IO to LOG_DEBUG_IO
[openocd.git] / src / jtag / drivers / mpsse.c
index 89248921ae46657cab6510557db4f5b964514682..a881803adfc10a0dc80f5a02008d503cf63cfd1f 100644 (file)
 #define LIBUSB_CALL
 #endif
 
-#ifdef _DEBUG_JTAG_IO_
-#define DEBUG_IO(expr...) LOG_DEBUG(expr)
 #define DEBUG_PRINT_BUF(buf, len) \
        do { \
-               char buf_string[32 * 3 + 1]; \
-               int buf_string_pos = 0; \
-               for (int i = 0; i < len; i++) { \
-                       buf_string_pos += sprintf(buf_string + buf_string_pos, " %02x", buf[i]); \
-                       if (i % 32 == 32 - 1) { \
-                               LOG_DEBUG("%s", buf_string); \
-                               buf_string_pos = 0; \
+               if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) { \
+                       char buf_string[32 * 3 + 1]; \
+                       int buf_string_pos = 0; \
+                       for (int i = 0; i < len; i++) { \
+                               buf_string_pos += sprintf(buf_string + buf_string_pos, " %02x", buf[i]); \
+                               if (i % 32 == 32 - 1) { \
+                                       LOG_DEBUG_IO("%s", buf_string); \
+                                       buf_string_pos = 0; \
+                               } \
                        } \
+                       if (buf_string_pos > 0) \
+                               LOG_DEBUG_IO("%s", buf_string);\
                } \
-               if (buf_string_pos > 0) \
-                       LOG_DEBUG("%s", buf_string);\
        } while (0)
-#else
-#define DEBUG_IO(expr...) do {} while (0)
-#define DEBUG_PRINT_BUF(buf, len) do {} while (0)
-#endif
 
 #define FTDI_DEVICE_OUT_REQTYPE (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE)
 #define FTDI_DEVICE_IN_REQTYPE (0x80 | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE)
@@ -458,7 +454,7 @@ static unsigned buffer_read_space(struct mpsse_ctx *ctx)
 
 static void buffer_write_byte(struct mpsse_ctx *ctx, uint8_t data)
 {
-       DEBUG_IO("%02x", data);
+       LOG_DEBUG_IO("%02x", data);
        assert(ctx->write_count < ctx->write_size);
        ctx->write_buffer[ctx->write_count++] = data;
 }
@@ -466,7 +462,7 @@ static void buffer_write_byte(struct mpsse_ctx *ctx, uint8_t data)
 static unsigned buffer_write(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset,
        unsigned bit_count)
 {
-       DEBUG_IO("%d bits", bit_count);
+       LOG_DEBUG_IO("%d bits", bit_count);
        assert(ctx->write_count + DIV_ROUND_UP(bit_count, 8) <= ctx->write_size);
        bit_copy(ctx->write_buffer + ctx->write_count, 0, out, out_offset, bit_count);
        ctx->write_count += DIV_ROUND_UP(bit_count, 8);
@@ -476,7 +472,7 @@ static unsigned buffer_write(struct mpsse_ctx *ctx, const uint8_t *out, unsigned
 static unsigned buffer_add_read(struct mpsse_ctx *ctx, uint8_t *in, unsigned in_offset,
        unsigned bit_count, unsigned offset)
 {
-       DEBUG_IO("%d bits, offset %d", bit_count, offset);
+       LOG_DEBUG_IO("%d bits, offset %d", bit_count, offset);
        assert(ctx->read_count + DIV_ROUND_UP(bit_count, 8) <= ctx->read_size);
        bit_copy_queued(&ctx->read_queue, in, in_offset, ctx->read_buffer + ctx->read_count, offset,
                bit_count);
@@ -500,10 +496,10 @@ void mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_of
        unsigned in_offset, unsigned length, uint8_t mode)
 {
        /* TODO: Fix MSB first modes */
-       DEBUG_IO("%s%s %d bits", in ? "in" : "", out ? "out" : "", length);
+       LOG_DEBUG_IO("%s%s %d bits", in ? "in" : "", out ? "out" : "", length);
 
        if (ctx->retval != ERROR_OK) {
-               DEBUG_IO("Ignoring command due to previous error");
+               LOG_DEBUG_IO("Ignoring command due to previous error");
                return;
        }
 
@@ -576,11 +572,11 @@ void mpsse_clock_tms_cs_out(struct mpsse_ctx *ctx, const uint8_t *out, unsigned
 void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_offset, uint8_t *in,
        unsigned in_offset, unsigned length, bool tdi, uint8_t mode)
 {
-       DEBUG_IO("%sout %d bits, tdi=%d", in ? "in" : "", length, tdi);
+       LOG_DEBUG_IO("%sout %d bits, tdi=%d", in ? "in" : "", length, tdi);
        assert(out);
 
        if (ctx->retval != ERROR_OK) {
-               DEBUG_IO("Ignoring command due to previous error");
+               LOG_DEBUG_IO("Ignoring command due to previous error");
                return;
        }
 
@@ -626,10 +622,10 @@ void mpsse_clock_tms_cs(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_
 
 void mpsse_set_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir)
 {
-       DEBUG_IO("-");
+       LOG_DEBUG_IO("-");
 
        if (ctx->retval != ERROR_OK) {
-               DEBUG_IO("Ignoring command due to previous error");
+               LOG_DEBUG_IO("Ignoring command due to previous error");
                return;
        }
 
@@ -643,10 +639,10 @@ void mpsse_set_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t d
 
 void mpsse_set_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t dir)
 {
-       DEBUG_IO("-");
+       LOG_DEBUG_IO("-");
 
        if (ctx->retval != ERROR_OK) {
-               DEBUG_IO("Ignoring command due to previous error");
+               LOG_DEBUG_IO("Ignoring command due to previous error");
                return;
        }
 
@@ -660,10 +656,10 @@ void mpsse_set_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t data, uint8_t
 
 void mpsse_read_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t *data)
 {
-       DEBUG_IO("-");
+       LOG_DEBUG_IO("-");
 
        if (ctx->retval != ERROR_OK) {
-               DEBUG_IO("Ignoring command due to previous error");
+               LOG_DEBUG_IO("Ignoring command due to previous error");
                return;
        }
 
@@ -676,10 +672,10 @@ void mpsse_read_data_bits_low_byte(struct mpsse_ctx *ctx, uint8_t *data)
 
 void mpsse_read_data_bits_high_byte(struct mpsse_ctx *ctx, uint8_t *data)
 {
-       DEBUG_IO("-");
+       LOG_DEBUG_IO("-");
 
        if (ctx->retval != ERROR_OK) {
-               DEBUG_IO("Ignoring command due to previous error");
+               LOG_DEBUG_IO("Ignoring command due to previous error");
                return;
        }
 
@@ -694,7 +690,7 @@ static void single_byte_boolean_helper(struct mpsse_ctx *ctx, bool var, uint8_t
        uint8_t val_if_false)
 {
        if (ctx->retval != ERROR_OK) {
-               DEBUG_IO("Ignoring command due to previous error");
+               LOG_DEBUG_IO("Ignoring command due to previous error");
                return;
        }
 
@@ -715,7 +711,7 @@ void mpsse_set_divisor(struct mpsse_ctx *ctx, uint16_t divisor)
        LOG_DEBUG("%d", divisor);
 
        if (ctx->retval != ERROR_OK) {
-               DEBUG_IO("Ignoring command due to previous error");
+               LOG_DEBUG_IO("Ignoring command due to previous error");
                return;
        }
 
@@ -817,7 +813,7 @@ static LIBUSB_CALL void read_cb(struct libusb_transfer *transfer)
                }
        }
 
-       DEBUG_IO("raw chunk %d, transferred %d of %d", transfer->actual_length, res->transferred,
+       LOG_DEBUG_IO("raw chunk %d, transferred %d of %d", transfer->actual_length, res->transferred,
                ctx->read_count);
 
        if (!res->done)
@@ -832,7 +828,7 @@ static LIBUSB_CALL void write_cb(struct libusb_transfer *transfer)
 
        res->transferred += transfer->actual_length;
 
-       DEBUG_IO("transferred %d of %d", res->transferred, ctx->write_count);
+       LOG_DEBUG_IO("transferred %d of %d", res->transferred, ctx->write_count);
 
        DEBUG_PRINT_BUF(transfer->buffer, transfer->actual_length);
 
@@ -851,13 +847,13 @@ int mpsse_flush(struct mpsse_ctx *ctx)
        int retval = ctx->retval;
 
        if (retval != ERROR_OK) {
-               DEBUG_IO("Ignoring flush due to previous error");
+               LOG_DEBUG_IO("Ignoring flush due to previous error");
                assert(ctx->write_count == 0 && ctx->read_count == 0);
                ctx->retval = ERROR_OK;
                return retval;
        }
 
-       DEBUG_IO("write %d%s, read %d", ctx->write_count, ctx->read_count ? "+1" : "",
+       LOG_DEBUG_IO("write %d%s, read %d", ctx->write_count, ctx->read_count ? "+1" : "",
                        ctx->read_count);
        assert(ctx->write_count > 0 || ctx->read_count == 0); /* No read data without write data */
 

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)