qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mac OS real USB device support issue


From: BALATON Zoltan
Subject: Re: Mac OS real USB device support issue
Date: Wed, 7 Apr 2021 12:27:00 +0200 (CEST)

On Wed, 7 Apr 2021, Howard Spoelstra wrote:
On Wed, Apr 7, 2021 at 7:26 AM Howard Spoelstra <hsp.cat7@gmail.com> wrote:
On Wed, Apr 7, 2021 at 3:53 AM Programmingkid <programmingkidx@gmail.com> wrote:
On Apr 6, 2021, at 7:18 PM, BALATON Zoltan <balaton@eik.bme.hu> wrote: Those might be a good place to start. IOKit provides the drivers and also the io registry which is probably where you can get if a driver is bound to a device and which one is it. How to dissociate the driver from the device though I don't know.

https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/IOKitFundamentals/DeviceRemoval/DeviceRemoval.html
According to this article a driver has a stop() and detach() method that is called by the IOKit to remove a device. I'm thinking QEMU can be the one that calls these methods for a certain device.

I think drivers are managed by IOKit so QEMU should and probably could not call driver methods directly. There should be some upper management layer to control this that you should talk to instead.

guest and connect passed through devices to that. Did USB 2 cards exist for older G3/G4 Macs?

Yes. I upgraded a friend's PowerMac G4 with such a card.

Some PowerBooks had USB 2 ports, what hardware did those use?

I'm assuming it was the G4 PowerBooks.

Could those be emulated in QEMU?

The PowerMac already is.

The PowerMacs don't have USB2, only USB1 I think and as Howard wrote MacOS does not have drivers either so you'd need to emulate the USB2 card and probably also need its driver from the FCode ROM on it or a new enough Mac OS X with USB2 drivers. Or pass through devices as USB1 but then you may need to somehow downgrade them to that level on the host for which using a USB1 only hub seems to work and as Howard found the hub in older Apple keyboards work for that.

This is what Gerd wrote about the USB 1.1 -> USB 2.0 issue:

"Problem is when the device is plugged into a usb2 port you can't query
the usb1 descriptors.  So qemu presents the wrong descriptors to the
guest in case host and guest use different usb speeds.  That may or may
not work ...

The other way around is less problematic, when plugging a usb2 device
into a usb3-capable (xhci) port I can tell the guest "this is a usb2
device".  But reporting "this is a usb2 device" via ohci isn't going to
fly for obvious reasons ..."

So then I forced my device it into USB 1.1 mode by attaching it to a
real 1.1 hub. The qemu hub will not do this for you. Mac OS and Mac OS
X guests up to 10.2.8 do not have USB 2.0 support, but from 10.2.8
upwards you can use the ehci hub. This works for a simple usb storage
device that uses the usbstorage kext in macOS. Indeed, as Zoltan
wrote, unloading a kext for a device that has its class driver loaded,
one looses access to other devices that match too. Reboot time ;-)

There used to be a solution by creating an empty kext that loaded with
higher priority compared to the standard kexts. I don't know whether
that solution could still work with Apple putting new requirements on
kext loading. I believe unloading a kext requires disabling SIP. Sudo
won't do anymore from Catalina upwards.

I gather Qemu is currenty relying on libusb to do the heavy lifting.
For Linux that seems OK together with perhaps first unbinding a
driver, but for macOS and Windows hosts the unbinding does not work.

Here is some discussion on how to create an empty kext:
https://github.com/libusb/libusb/issues/158#issuecomment-190582178

Best,
Howard

And this:
https://github.com/libusb/libusb/issues/906

That sounds like it could be what's needed, I haven't read it in detail but somebody could try to make a patch based on this info and test it if it still works with latest macOS.

Regards,
BALATON Zoltan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]