Skip to content

Commit

Permalink
UHCI: do not deactivate TDs on NAKs (#362)
Browse files Browse the repository at this point in the history
NAKs from USB devices do not deactivate TDs according to the official
UHCI spec (page 22).

Reference: http://ftp.netbsd.org/pub/NetBSD/misc/blymn/uhci11d.pdf
  • Loading branch information
Cacodemon345 authored Oct 21, 2024
1 parent ffb3b43 commit f6617f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions bochs/iodev/usb/uhci_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1009,11 +1009,11 @@ bool bx_uhci_core_c::DoTransfer(Bit32u address, struct TD *td)
}
}
if (ret >= 0) {
set_status(td, 0, 0, 0, 0, 0, 0, len-1);
set_status(td, 0, 0, 0, 0, 0, 0, 0, len-1);
} else if (ret == USB_RET_NAK) {
set_status(td, 0, 0, 0, 1, 0, 0, len-1); // NAK
set_status(td, 1, 0, 0, 0, 1, 0, 0, len-1); // NAK
} else {
set_status(td, 1, 0, 0, 0, 0, 0, 0x007); // stalled
set_status(td, 0, 1, 0, 0, 0, 0, 0, 0x007); // stalled
}
remove_async_packet(&packets, p);
return 1;
Expand All @@ -1032,13 +1032,14 @@ int bx_uhci_core_c::broadcast_packet(USBPacket *p)
}

// If the request fails, set the stall bit ????
void bx_uhci_core_c::set_status(struct TD *td, bool stalled, bool data_buffer_error, bool babble,
void bx_uhci_core_c::set_status(struct TD *td, bool active, bool stalled, bool data_buffer_error, bool babble,
bool nak, bool crc_time_out, bool bitstuff_error, Bit16u act_len)
{
// clear out the bits we can modify and/or want zero
td->dword1 &= 0xDF00F800;

// now set the bits according to the passed param's
td->dword1 |= active ? (1<<23) : 0; // active
td->dword1 |= stalled ? (1<<22) : 0; // stalled
td->dword1 |= data_buffer_error ? (1<<21) : 0; // data buffer error
td->dword1 |= babble ? (1<<20) : 0; // babble
Expand All @@ -1050,7 +1051,6 @@ void bx_uhci_core_c::set_status(struct TD *td, bool stalled, bool data_buffer_er
td->dword1 &= ~((1<<28) | (1<<27)); // clear the c_err field if there was an error
}


// pci configuration space write callback handler
void bx_uhci_core_c::pci_write_handler(Bit8u address, Bit32u value, unsigned io_len)
{
Expand Down
2 changes: 1 addition & 1 deletion bochs/iodev/usb/uhci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class bx_uhci_core_c : public bx_pci_device_c {
static void uhci_timer_handler(void *);
void uhci_timer(void);
bool DoTransfer(Bit32u address, struct TD *);
void set_status(struct TD *td, bool stalled, bool data_buffer_error, bool babble,
void set_status(struct TD *td, bool active, bool stalled, bool data_buffer_error, bool babble,
bool nak, bool crc_time_out, bool bitstuff_error, Bit16u act_len);

static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
Expand Down

0 comments on commit f6617f2

Please sign in to comment.