X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Fxscale.c;h=99f67aff57abe4dc61c8c3cf29f1832053463265;hb=3271e6d4d598f7221be339ec8449c25904538a4e;hp=3371a65d3e3926d45dd56c821368ea059c47b0f6;hpb=32ac9c0144f7aa7233b941bf78139eef8332fbc2;p=openocd.git diff --git a/src/target/xscale.c b/src/target/xscale.c index 3371a65d3e..99f67aff57 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -513,8 +513,6 @@ done: static int xscale_send(struct target *target, const uint8_t *buffer, int count, int size) { struct xscale_common *xscale = target_to_xscale(target); - uint32_t t[3]; - int bits[3]; int retval; int done_count = 0; @@ -522,37 +520,45 @@ static int xscale_send(struct target *target, const uint8_t *buffer, int count, XSCALE_DBGRX << xscale->xscale_variant, TAP_IDLE); - bits[0] = 3; - t[0] = 0; - bits[1] = 32; - t[2] = 1; - bits[2] = 1; + static const uint8_t t0; + uint8_t t1[4]; + static const uint8_t t2 = 1; + struct scan_field fields[3] = { + { .num_bits = 3, .out_value = &t0 }, + { .num_bits = 32, .out_value = t1 }, + { .num_bits = 1, .out_value = &t2 }, + }; + int endianness = target->endianness; while (done_count++ < count) { + uint32_t t; + switch (size) { case 4: if (endianness == TARGET_LITTLE_ENDIAN) - t[1] = le_to_h_u32(buffer); + t = le_to_h_u32(buffer); else - t[1] = be_to_h_u32(buffer); + t = be_to_h_u32(buffer); break; case 2: if (endianness == TARGET_LITTLE_ENDIAN) - t[1] = le_to_h_u16(buffer); + t = le_to_h_u16(buffer); else - t[1] = be_to_h_u16(buffer); + t = be_to_h_u16(buffer); break; case 1: - t[1] = buffer[0]; + t = buffer[0]; break; default: LOG_ERROR("BUG: size neither 4, 2 nor 1"); return ERROR_COMMAND_SYNTAX_ERROR; } - jtag_add_dr_out(target->tap, + + buf_set_u32(t1, 0, 32, t); + + jtag_add_dr_scan(target->tap, 3, - bits, - t, + fields, TAP_IDLE); buffer += size; } @@ -3388,7 +3394,7 @@ COMMAND_HANDLER(xscale_handle_trace_buffer_command) if (xscale->trace.mode != XSCALE_TRACE_DISABLED) { char fill_string[12]; - sprintf(fill_string, "fill %" PRId32, xscale->trace.buffer_fill); + sprintf(fill_string, "fill %d", xscale->trace.buffer_fill); command_print(CMD_CTX, "trace buffer enabled (%s)", (xscale->trace.mode == XSCALE_TRACE_FILL) ? fill_string : "wrap");