Add a helper function for running the queue if it would overflow otherwise.
Use it to simplify the queue fill level checks and optimize in a few cases
that would previously run the queue prematurely.
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
+/* runs the queue if it cannot take reserved_cmd bytes of command data
+ * or reserved_reply bytes of reply data */
+static
+int
+dtc_queue_run_if_full(
+ int reserved_cmd,
+ int reserved_reply
+) {
+ /* reserve one additional byte for the STOP cmd appended during run */
+ if (dtc_queue.cmd_index + reserved_cmd + 1 > USB_EP2BANK_SIZE)
+ return dtc_queue_run();
+
+ if (dtc_queue.reply_index + reserved_reply > USB_EP2IN_SIZE)
+ return dtc_queue_run();
+
+ return ERROR_OK;
+}
+
static
int
tap_state_queue_init(void) {
static
int
tap_state_queue_init(void) {
if ((bits >= 8) || !i) {
byte_param <<= (8 - bits);
if ((bits >= 8) || !i) {
byte_param <<= (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))) {
- dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
- DTC_CMD_STOP;
- dtc_queue_run();
- }
+ /* make sure there's room for two cmd bytes */
+ dtc_queue_run_if_full(2, 0);
#ifdef USE_HARDWARE_SHIFTER_FOR_TMS
if (bits == 8) {
#ifdef USE_HARDWARE_SHIFTER_FOR_TMS
if (bits == 8) {
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 */
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 (
- (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))
- ) {
- dtc_queue_run();
- }
+
+ /* make sure there's room for two cmd bytes */
+ dtc_queue_run_if_full(2, 0);
x = 0;
dtc_mask = 1 << (extra_bits - 1);
x = 0;
dtc_mask = 1 << (extra_bits - 1);
/* Loop scheduling full bytes into the DTC command buffer */
while (byte_bits) {
/* Loop scheduling full bytes into the DTC command buffer */
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 {
- /* make sure there's room for stop, byte op, and at least one byte */
- x = (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1));
- }
-
- 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) {
- dtc_queue_run();
- }
+ /* make sure there's room for one (for in scans) or two cmd bytes and
+ * at least one reply byte for in or inout scans*/
+ dtc_queue_run_if_full(type == SCAN_IN ? 1 : 2, type != SCAN_OUT ? 1 : 0);
chunk_bits = byte_bits;
/* we can only use up to 16 bytes at a time */
chunk_bits = byte_bits;
/* we can only use up to 16 bytes at a time */
if (extra_bits && (type != SCAN_OUT)) {
/* Schedule any extra bits into the DTC command buffer */
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 (
- (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))
- ||
- (dtc_queue.reply_index >= USB_EP2IN_SIZE - (1))
- ) {
- dtc_queue_run();
- }
+
+ /* make sure there's room for one (for in scans) or two cmd bytes
+ * and one reply byte */
+ dtc_queue_run_if_full(type == SCAN_IN ? 1 : 2, 1);
if (dtc_queue_enqueue_reply(
type, buffer, scan_size, tdi_bit_offset,
if (dtc_queue_enqueue_reply(
type, buffer, scan_size, tdi_bit_offset,
}
/* Schedule the last bit into the DTC command buffer */
}
/* Schedule the last bit into the DTC command buffer */
- /* make sure there's room for stop, and bit pair command */
- if (
- (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1))
- ||
- (dtc_queue.reply_index >= USB_EP2IN_SIZE - (1))
- ) {
- dtc_queue_run();
- }
+
+ /* make sure there's room for one cmd byte and one reply byte
+ * for in or inout scans*/
+ dtc_queue_run_if_full(1, type == SCAN_OUT ? 0 : 1);
if (type == SCAN_OUT) {
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
if (type == SCAN_OUT) {
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
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)