-
Notifications
You must be signed in to change notification settings - Fork 28
Description
I have a fix: https://www.mediafire.com/file/kvo6alj3t7tof8u/usb-xhci.c.zip/file
I know that Copilot AI gave me this fix (I uploaded usb-xhci.c.txt and usb-xhci.h.txt as reference (I renamed the files, because it only supports basic formats to upload onto Copilot), to avoid compilation errors, using the Smart (GPT 5) switch, but when I compiled, there were no errors. Because the AI has character limits, I added the small codes carefully, as instructed; everything else was not touched.
Try testing this on USB 3.0 devices on the desktop with CSMWrap and see if they still work.
So, the idea is that this fix stops USB 3.0 devices from turning off in real mode on CSMWrap (the problem is in SeaBIOS), which is the intended purpose.
Location: CSMWrap\seabios\src\hw\usb-xhci.c
Copilot (AI):
Here's a breakdown of what each of the four changes actually does in terms of functionality — and why they matter for USB HID devices (like keyboards and mice) on xHCI controllers in SeaBIOS/CSMWrap:
✅ Step 1: Accept CC_SHORT_PACKET in xhci_send_pipe()
Functionality:
Allows USB transfers to succeed even if the device sends less data than expected (a short packet).
This is normal behavior for HID devices during enumeration — they often send fewer bytes than requested.
Impact:
Without this fix, HID devices may fail to enumerate because SeaBIOS treats short packets as errors.
With this fix, short packets are accepted as successful transfers.
✅ Step 2: Power on ports + enable interrupts in configure_xhci()
Functionality:
- Powers on all USB ports before scanning for devices.
- Enables the xHCI interrupter and master interrupt so the controller can notify the BIOS of events.
Impact:
Some xHCI controllers (especially on laptops or newer chipsets) don’t power ports by default.
Without this, devices may never be detected.
With this fix, ports are guaranteed to be active and event notifications work reliably.
✅ Step 3: Warm reset for USB3 ports in xhci_hub_reset()
Functionality:
Issues a Warm Port Reset (WPR) on USB 3.0 ports to force the link to retrain and bring the port into the PED (Port Enabled/Disabled) state.
Impact:
On many Intel/AMD xHCI controllers, USB3 ports don’t automatically become active after a device is plugged in.
Without this, HID devices may appear “dead” or disconnected.
With this fix, the port link is retrained and the device becomes usable.
✅ Step 4: Safely clear change bits in xhci_process_events()
Functionality:
Clears only the RW1C (write‑1‑to‑clear) status change bits in the PORTSC register — without disturbing the link state or PED.
Impact:
The original code rewrote the whole PORTSC register, which could accidentally disable the port or change its link state.
With this fix, only the intended status bits are cleared, preserving the port’s active state.
🧠 Combined Effect
These four changes work together to:
- Prevent false errors during HID enumeration.
- Ensure ports are powered and responsive.
- Make USB3 ports behave like USB2 ports during reset.
- Avoid breaking port state during event handling.
Result:
USB keyboards and mice reliably enumerate and work in SeaBIOS/CSMWrap — even on tricky xHCI controllers.