Skip to content

Commit

Permalink
fixed bandwidth overage detection (#71)
Browse files Browse the repository at this point in the history
The check for the amount of byte transferred in one frame time was done
before the update of the vertical pointer in the current Queue of the
last executed TD. Therefore, on the next frame time, the last executed
TD was being "executed" again. The check has now been moved to the top
of the loop.
  • Loading branch information
fysnet authored Sep 5, 2023
1 parent fe53752 commit 0d48349
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bochs/iodev/usb/uhci_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,14 @@ void bx_uhci_core_c::uhci_timer(void)

// start the loop. we allow USB_UHCI_LOOP_COUNT queues to be processed
while (count--) {
// The UHCI (USB 1.1) only allows so many bytes to be transfered per frame.
// Due to control/bulk reclamation, we need to catch this and stop transferring
// or this code will just keep processing TDs.
if (bytes_processed >= hub.max_bandwidth) {
BX_DEBUG(("Process Bandwidth Limits for this frame (%d with a limit of %d).", bytes_processed, hub.max_bandwidth));
break;
}

if (!USB_UHCI_IS_LINK_VALID(item)) // the the T bit is set, we are done
break;

Expand Down Expand Up @@ -750,15 +758,7 @@ void bx_uhci_core_c::uhci_timer(void)

// we processed another td within this queue line
td_count++;

// The UHCI (USB 1.1) only allows so many bytes to be transfered per frame.
// Due to control/bulk reclamation, we need to catch this and stop transferring
// or this code will just keep processing TDs.
bytes_processed += r_actlen;
if (bytes_processed >= hub.max_bandwidth) {
BX_DEBUG(("Process Bandwidth Limits for this frame (%d with a limit of %d).", bytes_processed, hub.max_bandwidth));
break;
}

// move to the next item
if (!was_stall) {
Expand Down Expand Up @@ -1028,7 +1028,7 @@ void bx_uhci_core_c::set_status(struct TD *td, bool stalled, bool data_buffer_er
td->dword1 |= bitstuff_error ? (1<<17) : 0; // bitstuff error
td->dword1 |= (act_len & 0x7FF); // actual length
if (stalled || data_buffer_error || babble || crc_time_out || bitstuff_error)
td->dword1 &= ~((1<<28) | (1<<27)); // clear the c_err field in there was an error
td->dword1 &= ~((1<<28) | (1<<27)); // clear the c_err field if there was an error
}


Expand Down

0 comments on commit 0d48349

Please sign in to comment.