I am having similar problems to this guy on Stack Overflow over a year ago: https://stackoverflow.com/questions/77627852/functions-of-iouserscsiperipheraldevicetype00-class-in-scsiperipheralsdriverkit
There are also a few questions on this forum about this object, none of which have answers.
I can get my driver to match and instantiate, but nobody calls my UserDetermineDeviceCharacteristics (which does nothing, just returns kIOReturnSuccess)
I can attempt to call UserSuspendServices(), UserResumeServices() or UserReportMediumBlockSize() and all of them return kIOReturnUnsupported. It doesn't matter if I've unmounted the disk or not.
Is the custom driver supposed to be instantiated beside the kernel's IOSCSIPeripheralDeviceType00, or should it replace it?
What should its IOProviderClass be?
What should its IOClass be - IOUserService, or something else?
see FB19678139 and FB19677920
So, the first thing to understand here is that the "IOKitPersonalities" is called that because it IS in fact a fully valid "IOKitPersonalities" dictionary. That is, what the system actually uses that dictionary "for" is:
-
Perform a standard IOKit match and load cycle in the kernel.
-
The final driver in the kernel then uses the DEXT-specific data to launch and run your DEXT process outside the kernel.
So, working through the critical keys in that dictionary:
"IOProviderClass"-> This is the in-kernel class that your driver loads "on top" of. In your case, that would be IOSCSIPeripheralDeviceNub or one of its variants.
"IOClass"-> This is the in-kernel class that your driver loads on top of. This is where things can become a bit confused, as some families work by:
-
Routing all activity through the provider reference so that the DEXT-specific class does not matter (PCIDriverKit).
-
Having the DEXT subclass a specific subclass which corresponds to a specific kernel driver (SCSIPeripheralsDriverKit).
This distinction is described in the documentation, but it's easy to overlook if you don't understand what's going on. However, compare PCIDriverKit:
"When the system loads your custom PCI driver, it passes an IOPCIDevice object as the provider to your driver. Use that object to read and write the configuration and memory of your PCI hardware."
Versus SCSIPeripheralsDriverKit:
Develop your driver by subclassing IOUserSCSIPeripheralDeviceType00 or IOUserSCSIPeripheralDeviceType05, depending on whether your device works with SCSI Block Commands (SBC) or SCSI Multimedia Commands (SMC), respectively. In your subclass, override all methods the framework declares as pure virtual.
In addition, the reason these differences exist actually comes from the relationship and interactions between the DEXT families. Case in point, PCIDriverKit doesn't require a specific subclass because it wants SCSIControllerDriverKit DEXTs to be able to directly load "above" it.
That leads to:
What should its IOClass be -
It should be the same as whatever your DEXT subclasses- either "IOUserSCSIPeripheralDeviceType00" or "IOUserSCSIPeripheralDeviceType05".
IOUserService, or something else?
...and IOUserService is exactly what causes this:
I can attempt to call UserSuspendServices(), UserResumeServices() or UserReportMediumBlockSize() and all of them return kIOReturnUnsupported.
This is an undocumented implementation detail, but if there is a mismatch between your DEXT driver ("IOUserSCSIPeripheralDeviceType00") and your kernel driver ("IOUserService"), you end up trying to call unimplemented kernel methods. When a method is "missing" like that, the codegen system ends up handling that... by returning kIOReturnUnsupported.
Similarly:
I can get my driver to match and instantiate, but nobody calls my UserDetermineDeviceCharacteristics (which does nothing, just returns kIOReturnSuccess)
The component that would call those methods is the kernel driver your matching dictionary "told" the system to load.
I think that should be enough to get your DEXT sorted out, but if you're still having problems, please post the contents of your IOKitPersonalities dictionary, and I'll see if I can figure out where things are going wrong.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware