返回资讯中心
外部精选
软件工程
#开发者实时流

Bringing USB 3 and USB4/Thunderbolt to Windows 98 to 7

In my previous post, I introduced xHCI98, a driver that gives Windows 98 SE, ME, 2000, XP, Vista and 7 working USB on machines whose only USB controller is eXtensible Host Controller Interface (xHCI), the only kind most…

Hacker News 最新yeokm12026/10/17 · 2026/10/1730 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

In my previous post, I introduced xHCI98, a driver that gives Windows 98 SE, ME, 2000, XP, Vista and 7 working USB on machines whose only USB controller is eXtensible Host Controller Interface (xHCI), the only kind most modern machines have.

That version had a catch. It only drove the USB 2.0 side of the controller, so even a USB 3.0 flash drive was capped at around 34 MB/s.

After that, I decided to go further by giving this driver both USB 3.x and USB4/Thunderbolt support. The latter is so modern that not even all of today’s machines have it.

The project source code is still at the same link: https://github.com/yeokm1/xhci98

I decided to write this blog post to share my journey on how I managed to add this support in.

As with the previous post, most of the words in this blog post are written by me. AI was primarily used to generate the diagrams and tables.

To recap, the initial release of xHCI98 was a miniport driver under Microsoft’s usbport.sys. This is the same architecture as Microsoft’s original UHCI, OHCI and EHCI drivers.

The problem is that usbport.sys is a USB 2.0-era design. It has no concept of what SuperSpeed is.

At that time, I wrote that doing USB 3 properly would mean replacing the entire HCD stack and that would incur additional effort, token cost and testing.

Besides, every USB 3 device by the standard should degrade gracefully to 480 Mbps USB 2.0 speeds. So I left it at that and asked the xHCI controller to power down all the USB 3.0 connections leaving only the USB 2.0 lines in the connector active.

What changed my mind was not speed. It was the growing list of workarounds I needed to accommodate usbport.sys’s limitations.

usbport.sys assumes an EHCI world. On EHCI, a USB 1.1 Full-Speed or Low-Speed device never sits directly on a USB 2.0 root port. It is always handed off to a separate companion controller UHCI/OHCI or goes through a hub’s Transaction Translator (TT).

xHCI has no such split as it handles all the standards by itself. A USB 1.1 device like a mouse on a root port made usbport.sys look for a TT. When that did not exist, the operating system hung.

The workaround I employed then was to report every root port device as High-Speed. This had some repercussions:

In my final attempt to solve this problem, I had even added an experimental “virtual USB 2.0 hub” per root port. Basically every non-High-Speed device connected to a root port would have a virtual USB 2.0 hub sitting inline as a middleman just to give usbport.sys the TT it wanted to see.

This added plenty of edge cases like connection and disconnection which had to be carefully tested. It also had the side effect of using up one of the 5 hub tiers that USB allows.

I expected that in the long run this would get even more problematic as new bugs are reported in code I cannot control or when I want to add features that usbport.sys cannot support.

I finally had enough. The cost of staying on the old architecture had grown to the point where it no longer justified its benefits. I should stop plugging into usbport.sys and take over its functions altogether. And I thought since I was doing this anyway, the original constraint of not doing USB 3.0 speeds was now gone.

xHCI98 2.x supports USB 3.0. Everything between the class drivers and the hardware is now my driver. Microsoft’s usbport.sys, usbhub.sys and the composite parent are no longer needed and the USB 3.x ports are no longer left unpowered.

The new xhci98.sys is a single bus driver that takes on several roles previously done by

The class drivers above it are still the same. I chose to stay compatible with the existing class drivers rather than reimplementing them as they are mature, have been used for decades and it keeps any third-party vendor driver working too.

There is also a second driver, xhciuas.sys, for USB Attached SCSI (UAS) storage. UAS is the faster storage protocol most USB 3 drives and SATA bridges support as opposed to the older Bulk-Only Transport that usbstor.sys uses. Although UAS drives are supposed to be able to fall back to Bulk-Only mode, I added UAS support in response to a user request as some UAS drives misbehave and don’t want to use Bulk mode.

The P14s on Windows 98 SE with the USB 3 flash drive, plus a hub with a Transcend StoreJet drive, a USB sound card and an Ethernet adapter. Device Manager lists the xHCI98 controller, hubs, UAS storage and composite devices.

After I released the SuperSpeed version of the driver, user reports slowly came in as more people tried it on hardware I did not own.

On Intel 7, 8 and 9-series chipsets (Ivy Bridge to Broadwell), the blue USB 3 ports are wired to both the EHCI and xHCI controllers. With the BIOS on “Auto”, they start out on EHCI. So a USB 3 flash drive either runs at USB 2.0 speed or is invisible to xHCI98. This was done to ensure compatibility with OSes of that period, which did not all support xHCI, or did not support it during setup.

The driver can now flip those ports over to xHCI using the chipset registers when it starts and hand them back when it stops. A tester reminded me about this issue which I had initially missed.

The switch is done by writing to 2 registers in the xHCI controller’s PCI configuration space:

Lenovo B490’s BIOS with the “USB 3.0 Mode” option. On “Auto”, the shared ports start out on the EHCI controller unless commanded by the driver to switch. Other options can manually force a switch.

On a 2015 Dell Latitude E7250 (Broadwell), after the driver was installed and the ports switched to USB 3.0 in the BIOS, the mouse was sluggish, disks never mounted and Windows would hang occasionally.

It turned out the BIOS programmed the chipset to send the xHCI interrupt to IRQ 16 while ACPI told Windows it was on IRQ 21. EHCI also used IRQ 21. Since IRQ 21 was only used by the EHCI controller, it had little activity once the USB ports were switched over from EHCI to xHCI. My interrupt handler only ever ran when EHCI happened to interrupt on the same line!

Nobody noticed this BIOS bug for years because Intel’s Windows 7 driver and Windows 8+ driver both use Message Signaled Interrupts (MSI) which do not use legacy interrupts at all.

With AI’s help and RW-Everything, the wrong-IRQ hypothesis was tested by rewriting the chipset routing register live to the correct IRQ value.

The E7250 on Windows XP. The XHCISNAP (my driver diagnostic and logging tool) report in Notepad.

It shows the driver rerouting the xHCI interrupt from PIRQA to PIRQF so it arrives on IRQ 21 where Windows expects it.

The E7250 taught me that I cannot always trust the legacy interrupt line. So the driver gained two alternatives.

On 2 Intel Sunrise Point machines, my 2016 ThinkPad E460 and a community-tested 2018 HP EliteBook 850 G5, USB 3 flash drives were completely invisible. A USB 3 hub only showed as a USB 2.0 hub.

I took register snapshots using my XHCISNAP tool which showed the link was actually training fine at SuperSpeed.

The real cause was a speed table the controller publishes. On Sunrise Point, it only lists Intel’s internal SSIC chip-to-chip speeds (1248/2496/4992 Mb/s). My driver read that table as replacing the standard speed IDs rather than adding to them. So a normal SuperSpeed device was reported as “unknown speed” and dropped before it was even given a device slot.

I pointed the AI at the Linux source to see how it handled this. It turned out Linux never maps speeds through that table, which is why it never hit this issue. The fix was to let unlisted standard IDs fall back to their usual meanings.

A tester on an AMD AM5 board reported their mouse “randomly stops” and once a device was dead, the only way to recover was to replug the device.

My driver was stricter than Linux when a controller misbehaved. I referred to how Linux handles these and added seven tolerant behaviours, such as retrying transaction errors, recovering a halted endpoint, bringing back a port the controller disabled and recovering a halted controller.

From the Linux source code as well, I added quirk management for controllers from many vendors like Fresco Logic, ASMedia, AMD, TI, Etron, VIA and some Intel controllers.

I got a report that on a VIA VL805 PCIe card, every Low and Full-Speed device was silently ignored. There was no error and no yellow exclamation mark.

The VL805 routes everything on the USB 2.0 side through an integrated hub, so its port speed table only lists High-Speed.

My driver wrongly used that table to judge the devices behind the hub too. I fixed it purely from logs provided by the reporter as I don’t own a VL805. The fix was later confirmed working.

Every xHCI controller reports which revision of the specification it was built to. My driver was written against xHCI 1.0 onwards and refused anything below that as a safety mechanism. This will result in a Code 10 “This device cannot start” in Device Manager.

It turns out the very first generation of USB 3.0 controllers are xHCI 0.96 parts. These are the NEC/Renesas uPD720200 and ASMedia ASM1042 chips found on many early USB 3.0 PCIe add-in cards and 2010-era motherboards.

The xHCI specification was still a draft back then and Linux writes a few fields differently on these parts. The TD Size field counts in 1 KiB units rather than packets, some control and isochronous fields have to be written as 0, and one capability register does not exist so a resume from standby re-enumerates the devices.

I followed what Linux does and from 2.4.0.0 the driver accepts 0.96 controllers by default, with a registry switch to refuse them again.

64-bit Windows Vista and 7 refuse to load a kernel driver that is not signed and Microsoft no longer signs drivers for these legacy OSes. The only way to load the x64 driver was to press F8 and choose “Disable Driver Signature Enforcement” at every single boot which is a hassle and easy to miss.

The x64 drivers are now test-signed with the project’s own certificate. Users can now just boot their machines in test-signing mode and the driver loads on every boot without pressing F8. Windows will still warn that it cannot verify the publisher during installation, which is expected as this is not a Microsoft signature.

At the end of it, I did some benchmarking and the speed is approximately 200+ MB/s. A respectable figure for Windows 98.

The speed flatlines from 64 KB transfers onwards because of the 64 KB request size limit imposed by Windows’s USB storage driver.

Now that USB 3 is done, what is the next step?

The newer USB4 and Thunderbolt standards of course!

USB4 and Thunderbolt 3 are quite different from USB 3. A USB4 dock is not a USB device. It is closer to a network switch, a bunch of routers that carry other protocols inside tunnels. PCIe, USB 3 and DisplayPort each get their own tunnel.

There are three ways to get a USB4/Thunderbolt device working with an operating system.

Once a PCIe tunnel is up, a device inside the dock like an NVMe drive simply appears on the PCIe bus as if it were plugged into the motherboard. Windows can then use an existing PCI driver for it.

Since the first requires no driver effort, xHCI98 v3 covers options 2 and 3 with a new xhcicm.sys driver installed beside xhci98.sys. Like xhci98.sys, it runs on everything from Windows 98 SE to Windows 7, and it picks the right mode for each controller automatically:

The PCIe devices behind the tunnel then use their own drivers. The xHCI controller inside a dock is driven by xhci98.sys itself, and an NVMe drive by Stor98.

This is the high-level architecture of how xHCI98 v3 works.

Other than the driver, I also built a helper tool, xHCI98 USB Tree. It is modelled on Microsoft’s USB Device Viewer (usbview) to display useful information about the USB and Thunderbolt devices as well as to safely

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →