From f6617f29d6181fd652055e0749908c0bd7129f45 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Mon, 21 Oct 2024 20:10:19 +0600 Subject: [PATCH] UHCI: do not deactivate TDs on NAKs (#362) 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 --- bochs/iodev/usb/uhci_core.cc | 10 +++++----- bochs/iodev/usb/uhci_core.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bochs/iodev/usb/uhci_core.cc b/bochs/iodev/usb/uhci_core.cc index 90ba8c6d5..45bd8e8ce 100644 --- a/bochs/iodev/usb/uhci_core.cc +++ b/bochs/iodev/usb/uhci_core.cc @@ -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; @@ -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 @@ -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) { diff --git a/bochs/iodev/usb/uhci_core.h b/bochs/iodev/usb/uhci_core.h index 28b339a87..227f32942 100644 --- a/bochs/iodev/usb/uhci_core.h +++ b/bochs/iodev/usb/uhci_core.h @@ -215,7 +215,7 @@ protected: 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);